when a user clicks in the multiline tb provider to edit existing text or add a new row, i would like to increase the number of rows to 10
Currently, the textbox has only enough rows to accommodate the text - even though i set it to 10 in the provider
I would like to increase this in the cell edit entering event, if possible
I have this so far
function grid_CellEditing_EnteringEditMode(sender, e) { var c = e.getCell(); var key = c.get_column().get_key();
// Add a new line to log_text if (key == "log_text") { var t = c.get_value(); // Add a blank line and, ideally, set cursor to end if (t != "") c.set_value(t + "\r\n");
i need to do something equivalent to
c.rows.count = 10
markup
<EditorProviders> <ig:TextBoxProvider ID="Chrono_MultiLineTextBoxProvider"> <EditorControl ClientIDMode="Predictable" Height="300px" MaxLength="10000" TextMode="MultiLine" Width="500px" Rows="10"></EditorControl> </ig:TextBoxProvider>
Thanks!
Hello Peter,
This could be achieved by changing the value of the cell that contains the Multiline TextEditorProvider and adding the empty lines in the EnteredEditMode event of the grid, after the user has finished editing the cell value, the ExitedEditMode event should be used and the value of the cell should be trimmed in order to not save the empty lines at the end. In case you would like to use the enter for creating new line inside the cell, the ExitingEditMode event could be used, the enter key press should be checked and the ExitingEditMode should be cancelled to retain edit mode.
I am pasting the code for the events below:
function WebDataGrid1_CellEditing_ExitingEditMode(sender, eventArgs) { if (eventArgs.getCell().get_column().get_key() == "Site") { if (eventArgs.get_browserEvent().keyCode == 13) { eventArgs.set_cancel(true); } } } function WebDataGrid1_CellEditing_EnteredEditMode(sender, eventArgs) { var cell = eventArgs.getCell() if (cell.get_column().get_key() == "Site") { var cellValue = cell.get_value() + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n"; cell.set_value(cellValue); } } function WebDataGrid1_CellEditing_ExitedEditMode(sender, eventArgs) { var cell = eventArgs.getCell() if (cell.get_column().get_key() == "Site") { var cellValue = cell.get_value(); cellValue = cellValue.trim(); cell.set_value(cellValue); } }
Please let me know if you have any questions.
Regards, Ivan Kitanov
Further to that, do you know a way of setting the cursor at the end ready to type ? Currently it selects the contents and user needs to click at the end.
Also, a related question.
When i add a row (in javascript) the formatting is a little wonky. a skinny text box is added below the new line. when i click in the field, it is ok, but it looks weird and is going to confuse the users
I appreciate your help. Thanks
Here is markup
var grid = GetGrid(); var rows = grid.get_rows(); var rowsLength = rows.get_length();
// Create array of cell values for all values that cannot be null. var est = new Date().toLocaleString('en-US', { timeZone: 'EST' }); var row = new Array(est, "", "", "\n\n\n\n\n", false, "<%=Master.UserName%>", "");
rows.add(row);
var lastRow = rows.get_row(rowsLength); var cell = lastRow.get_cell(c_col_sci); grid.get_behaviors().get_editingCore().get_behaviors().get_cellEditing().enterEditMode(cell);
Yes, that is what i am doing, but i thought there might be a more elegant solution.
it would be nice to programmatically set the row count