jQuery UI Widgets › Forums › Grid › enter focus problem textarea in jqxGrid
Tagged: focus enterkey, grid, jqwidgets
This topic contains 2 replies, has 2 voices, and was last updated by devsim 4 years, 9 months ago.
-
Author
-
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
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 StoevjQWidgets Team
https://www.jqwidgets.comAfter 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();
}—
-
AuthorPosts
You must be logged in to reply to this topic.