I'm using kendo grid in inline GridEditMode and GridInsertRowPosition set to bottom. Ajax is used for the data binding. Sorting is enabled and sorted by DateTime field. Page size is set to 10.
To problem occur when there are multiple pages (more that 10 records). I have a javascript function that jumps to the last page and show new row at the bottom. But on some point sort event is triggered, and grid moves to read only mode.
Is there a possibility to prevent Grid sorting only for the case when new row is added?
Any help is welcome. Thank you!
You should define a custom command in your toolbar as:
toolbar : [
{
name : "my-create",
text : "Add new record"
}
],
Then, add an event listener to it, using as selector k-grid-
plus the name of the command.
$(".k-grid-my-create", grid.element).on("click", function (e) {
}
Finally we will use the ability of Kendo UI datasource for inserting in a specific point:
var dataSource = grid.dataSource;
var total = dataSource.data().length;
dataSource.insert(total, {});
dataSource.page(dataSource.totalPages());
grid.editRow(grid.tbody.children().last());
Please, realize that we should move to the last page after inserting the row. This should be ok with having columns sorted by date.
Please, check the code here: http://jsfiddle.net/OnaBai/sAVGk/
Check out new kendo setting: createAt
just set it to the 'bottom':
...
createAt: 'bottom',
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With