Hello,
I have a WebDataGrid (and WebHierarchicalDataGrid) with EditingCore and RowEditing activated. One of the cells is a multiline text which I would like to edit (and being able to add new lines by pressing enter). However, by default, Enter closes the EditingMode.
So, first of all I added the following Editor:
<EditorProviders>
<ig:TextBoxProvider ID="NewsTextEditor">
<EditorControl ID="NewsTextEditor" ClientIDMode="Predictable" TextMode="MultiLine"></EditorControl>
</ig:TextBoxProvider>
</EditorProviders>
And assigned it to the RowEditing-ColumnSettings for the particular Field. Now, I found a solution in the forum if one uses the CellEditing by doing the following:
function WebHierarchicalDataGrid1_CellEditing_ExitingEditMode(sender, eventArgs) {
if (eventArgs.getCell().get_column().get_key() == "NEWS_TEXT") {
if (eventArgs.get_browserEvent().keyCode == 13) {
eventArgs.set_cancel(true);
}
However, when using RowEditing, There is no eventArgs.getCell(), and even if I would ignore the column check and just cancle the Event every time:
function WebHierarchicalDataGrid1_RowEdit_ExitingEditMode(sender, eventArgs) {
eventArgs.set_keepEditing(true);
it does not add a new line to the text. What can I do to use multiline Editors with the RowEditing Behaviour?
Thanks a lot!
Thank you for reporting this.
I have asked our engineering staff to examine this further. To ensure that it will receive attention, I have logged this behaviour in our internal tracking system with a Development ID of 204817. A support case is created on your behalf with number CAS-162255-M2R5X9 , so that you can be notified when the bug is fixed. You can find your active cases under Account - Support Activity in our website. Select your ticket and go to Development Issues tab to view the status of related bugs.
Let me know if I may be of further assistance.
Hi Nadia,
Thanks for creating a ticket.
I managed to create the following Workaround in the meantime, by intercepting the KeyDown Event in case Enter is pressed within a textarea and manually insert a linebreak and maintain the selection/cursor position.
function commonGridInitializeHandler(sender, eventArgs) {
$("#ctl00_MainContent_WebHierarchicalDataGrid1_ctl00_NewsEditor").on('keydown', function (e) {
if (e.keyCode == 13) {
e.preventDefault();
var sel = getInputSelection(this);
this.value = this.value.substring(0, this.selectionStart) + "\n" + this.value.substring(this.selectionEnd, this.value.length);
setInputSelection(this, sel.start, sel.end);
return false;
});
function getInputSelection(el) {
var start = 0, end = 0, normalizedValue, range, textInputRange, len, endRange;
if (typeof el.selectionStart == "number" && typeof el.selectionEnd == "number") {
start = el.selectionStart;
end = el.selectionEnd;
} else {
range = document.selection.createRange();
if (range && range.parentElement() == el) {
len = el.value.length;
normalizedValue = el.value.replace(/\r\n/g, "\n");
// Create a working TextRange that lives only in the Input
textInputRange = el.createTextRange();
textInputRange.moveToBookmark(range.getBookmark());
// Check if the start and end of the selection are at the very end
// of the input, since moveStart/moveEnd doesn't return what we want
// in those cases
endRange = el.createTextRange();
endRange.collapse(false);
if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
start = end = len;
start = -textInputRange.moveStart("character", -len);
start += normalizedValue.slice(0, start).split("\n").length - 1;
if (textInputRange.compareEndPoints("EndToEnd", endRange) > -1) {
end = len;
end = -textInputRange.moveEnd("character", -len);
end += normalizedValue.slice(0, end).split("\n").length - 1;
return {
start: start,
end: end
};
function offsetToRangeCharacterMove(el, offset) {
return offset - (el.value.slice(0, offset).split("\r\n").length - 1);
function setInputSelection(el, startOffset, endOffset) {
el.selectionStart = startOffset+1;
el.selectionEnd = endOffset + 1;
var range = el.createTextRange();
var startCharMove = offsetToRangeCharacterMove(el, startOffset);
range.collapse(true);
if (startOffset == endOffset) {
range.move("character", startCharMove);
range.moveEnd("character", offsetToRangeCharacterMove(el, endOffset));
range.moveStart("character", startCharMove);
range.select();
Could you please let me know what is the status of the issue after installing our latest SR.
Thank you!