jQuery UI Widgets Forums Grid enter focus problem textarea in jqxGrid

This topic contains 2 replies, has 2 voices, and was last updated by  devsim 4 years, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author

  • devsim
    Participant

    Hello
    My English is poor. n_n;;;;;

    I saw the issue

    https://www.jqwidgets.com/community/topic/overriding-enter-key-in-textarea-of-editable-jqx-grid/

    Hristo’s answer

    Here is example in textArea

    ——
    apple
    bro
    camera
    ——

    1. When I located curser last the apple

    ——
    apple_
    bro
    camera
    ——

    2. Press Enter key, curser located bottom of camera

    ——
    apple
    bro
    camera
    _
    ——

    3. I think cause of this Code -> ‘ currentContent = editorElement.val() + \n ‘

    so. how do I solved the problem ?

    I Want like this

    ——
    apple
    _
    bro
    camera
    ——

    thanks


    Peter Stoev
    Keymaster

    Hi devsim,

    Thank you for using jQWidgets Grid.

    You can use the editorElement.focus() to put the focus to the first character in the editor.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    https://www.jqwidgets.com


    devsim
    Participant

    After 11 months later

    I solved the problem myself.

    This is My solution

    var editorElement = null;
    var currentContent = ”;

    $(“#devsimGrid”).jqxGrid({

    handlekeyboardnavigation: function (event) {
    var key = event.charCode ? event.charCode : event.keyCode ? event.keyCode : 0;

    if (key == 13) {
    var txtArea = editorElement[0];
    var txtValue = txtArea.value;
    var selectPos = txtArea.selectionStart;
    var beforeTxt = txtValue.substring(0, selectPos);
    var afterTxt = txtValue.substring(txtArea.selectionEnd, txtValue.length);

    currentContent = beforeTxt + “\n” + afterTxt;
    editorElement.val(currentContent);

    var pos = (selectPos+1);
    var obj = document.getElementById(“customTextArea0TextArea”);
    if (obj.setSelectionRange) {
    obj.focus();
    obj.setSelectionRange(pos, pos);
    }
    else if (obj.createTextRange) {
    var c = obj.crateTextRange();
    c.move(“character”, pos);
    c.select();
    }

    return true;
    } else if (key == 27) {
    return true;
    }
    },

    }, {
    text: ‘Work’,
    editable: true,
    datafield: ‘Work’,
    width: ‘380px’,
    align: ‘center’,
    cellsrenderer: textrenderer,
    columntype: ‘template’,
    createeditor: function(row, cellvalue, editor, celltext, cellwidth, cellheight) {
    editorElement = $(‘<textarea id=”customTextArea’ + row + ‘”></textarea>’).prependTo(editor);
    editorElement.jqxTextArea({
    height: 88,
    width: ‘100%’
    });
    },
    initeditor: function (row, cellvalue, editor, celltext, pressedChar) {
    currentContent = ”;
    editorElement.val(cellvalue);
    },
    geteditorvalue: function (row, cellvalue, editor) {
    return editor.find(‘textarea’).val();
    }

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.