Hi All,
Is there a way to enable user to input MultiLine in a text field?
I tried TextBoxProvider and TextEditorProvider both seems not working.
When the user press "Enter" key, the field just exit edit mode but not go to the next line within the textbox.
Thanks!
David
davidwsk said:When the user press "Enter" key, the field just exit edit mode but not go to the next line within the textbox.
Hello David,
With the suggested manner above the user will be able to edit a cell and when the text of the cell reaches the end automatically the cursor is pushed to the next line and it is not needed the user to press enter. But if you want to do that on enter press or you want to implement custom logic and so on you can use provided by the grid client - side evnt handlers.
Please provide and example of how you would use the client side event handlers to allow the user to press the enter key to add a a new line to the text. Changing the textmode to Multiline just allows for WRAPPING, which is NOT the same as true multi-line editing. The fact that the editor doesn't support or allow true multi-line editing (with the user able to add multiple lines by hitting the enter key) is absurd. If you are going to propose a work around to your products gross limitations, please have the courtesy to provide an example of how you would implement such a work around for such a basic missing feature.
Hi,
I got the solution. But one doubt How to set the MaxLength for this textbox to the "4"
Thanks in Advance.
Hello,
If the TextMode is SingleLine, then you can set the Maxlength to be 4 and this will limit the input to be only 4 characters. The MaxLength has no affect when TextMode is MultiLine.
If you really want to limit the number of characters to 4, on a multiline editor then you would need to use JavaScript to limit the number of characters that can be entered. You can do this by giving the editor provider a static id:
<EditorProviders> <ig:TextBoxProvider ID="WebDataGrid1_TextBoxProvider1"> <EditorControl ID="SiteEditor" ClientIDMode="Static" TextMode="MultiLine" MaxLength="4" Rows="4"> </EditorControl> </ig:TextBoxProvider></EditorProviders>
Then add a client side event for the initialization of the grid:
<ClientEvents Initialize="WebDataGrid1_Initialize"></ClientEvents>
In the event handler, get the TextArea that is used as the editor and set the onkeydown event:
function WebDataGrid1_Initialize(sender, eventArgs) { var editor = document.getElementById("SiteEditor"); editor.onkeydown = function(e) { // don't cancel the event if the backspace or delete key was pressed. if (e.keyCode == 8 || e.keyCode == 46) return true; // cancel the event if the length of the editor is 4 or more. if (editor.value.length >= 4) return false; };}
Let me know if you have any questions with this matter.
I tired but it is giving the error. So I attached the error screen shot and sample code along with this forum.
Please check and correct it that code and send it back.
I am waiting for your reply.
Praveena,
When running the page that you provided with the same version of the NetAdvantage assemblies that you reference I don't reproduce the issue. Let me know what web browser are you using and I will test again.
We are using IE 8 and on Page load itself it getting that error. And in firefox and chrome there is no error but it is allowing more than max length i.e. more than 4 characters.
Please do the needful and I am waiting for your message.
Thanks in advance.
Hello Praveen,
Please let me know if I can provide any further assistance regarding this matter.
To prevent the cell from existing edit mode when tab is pressed, Webdatagrid's KeyDown and cell exiting edit mode clients side events needs to be handled like below
function WebDataGrid1_Grid_KeyDown(sender, eventArgs) { var editedColumn = ""; if (sender.get_behaviors().get_editingCore().get_behaviors().get_cellEditing().get_cellInEditMode() != null ) { editedColumn = sender.get_behaviors().get_editingCore().get_behaviors().get_cellEditing().get_cellInEditMode().get_column().get_key(); } if (editedColumn == "Name") { if (eventArgs.get_browserEvent().keyCode == 9 || eventArgs.get_browserEvent().keyCode == 13) { eventArgs.set_cancel(true); }}} function WebDataGrid1_CellEditing_ExitingEditMode(sender, eventArgs) { if (eventArgs.getCell().get_column().get_key() == "Name") { if (eventArgs.get_browserEvent().keyCode == 9 || eventArgs.get_browserEvent().keyCode == 13) { eventArgs.set_cancel(true); }}}
{ var editedColumn = "";
if (sender.get_behaviors().get_editingCore().get_behaviors().get_cellEditing().get_cellInEditMode() != null ) {
editedColumn = sender.get_behaviors().get_editingCore().get_behaviors().get_cellEditing().get_cellInEditMode().get_column().get_key();
}
if (editedColumn == "Name") {
if (eventArgs.get_browserEvent().keyCode == 9 || eventArgs.get_browserEvent().keyCode == 13) {
eventArgs.set_cancel(true);
}}}
function WebDataGrid1_CellEditing_ExitingEditMode(sender, eventArgs)
{
if (eventArgs.getCell().get_column().get_key() == "Name") {
Attached sample demonstrates the same.
The have tried to cancel the event when the tab key is pressed but the cell is exiting from the editmode. So, I am currently discussing with our Development team regarding this matter and I will update you by the end of the day tomorrow with the progress.
Please let me know if you have any further questions regarding this matter
Like a multiline when the tab key is pressed inside the particular column cancel the event and it should work as a tab in the notepad.
Please do the needful.
Hello Praveena,
I would recommend you to use TextEditorProvider as shown below:
<EditorProviders> <ig:TextEditorProvider ID="WebDataGrid1_TextEditorProvider1"> <EditorControl ClientIDMode="Predictable" MaxLength="4" MultiLine-Rows="4" TextMode="MultiLine"> </EditorControl> </ig:TextEditorProvider> </EditorProviders>
This will limit number of character to 4, It is not needed to write any custom code.
I hope this helps.