Kendo grid Insert new record on last page, last row position

I use the kendo grid in the built-in grids GridEditMode and GridInsertRowPosition set from below. Ajax is used to bind data. Sorting is enabled and sorted by the DateTime field. The page size is 10.

The problem occurs when there are several pages (more than 10 entries). I have a javascript function that jumps to the last page and shows a new line at the bottom. But at some point a sorting event occurs, and the grid goes into read-only mode.

Is it possible to prevent Grid sorting only when a new row is added?

Any help is appreciated. Thanks!

+3
source share
3 answers

You should define a custom command on the toolbar like this:

toolbar : [ { name : "my-create", text : "Add new record" } ], 

Then add an event listener to it, using k-grid- plus the name of the command as a selector.

 $(".k-grid-my-create", grid.element).on("click", function (e) { } 

Finally, we will use the Kendo UI data source ability to insert at 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 understand that we must go to the last page after inserting the line. This should be fine with columns sorted by date.

Please check the code here: http://jsfiddle.net/OnaBai/sAVGk/

+7
source

Check out the new kendo setting: createAt

just set it to the bottom:

 ... createAt: 'bottom', ... 
+6
source

Is it possible to prevent Grid sorting only when a new row is added?

In the add handler window, use the following code:

  var table = $("#gridId").data("kendoGrid"); var sorting = table.dataSource.sort(); if (sorting) { table.dataSource.sort(null); } table.addRow(); 

The sort will be deleted and the new item will be in edit mode.

0
source

All Articles