Cell edit using Multiline Textbox in JavaScript Grid
By default, the TextBox control will be used as a default editor control for the string column in Javascript Grid. You can customize the editor control using Multiline Textbox by rendering it as a custom component in the Grid edit form.
You can use the cellEditTemplate feature of Grid to render the Multiline TextBox component in the Grid edit form. The cell edit template is used to add a custom component for a particular column by invoking the create, write, read, and destroy functions.
edit: { create: function () { elemContent = document.createElement('textarea'); return elemContent; }, destroy: function () { textEditor.destroy(); }, read: function () { return textEditor.value; }, write: function (args) { textEditor = new TextBox({ multiline: true, value: args.rowData[args.column.field], floatLabelType: 'Auto' }); textEditor.appendTo(elemContent); } }
Using the valueAccessor feature of Grid, you can split the value into multiple lines in the Grid column.
When editing a particular cell in the Grid, you can prevent the ENTER key’s functionality using the created event in the Grid.
function valueAccessor(field, data, column) { var value = data[field]; if (value != undefined) { return value.split('\n').join('<br>'); } else { return ''; } } created: function (args) { this.keyConfigs.enter = ''; }
Output
You can find the sample here:
Documentation
https://ej2.syncfusion.com/documentation/textbox/multiline/
https://ej2.syncfusion.com/documentation/grid/edit/#cell-edit-template