Guest User

Untitled

a guest
Jan 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. var grid = $("#grid").getKendoGrid();
  2. grid.bind("saveChanges", function (e) {
  3. var data = grid.dataSource.data();
  4.  
  5. // collect updated rows and new rows
  6. var items = $.grep(data, function (item) {
  7. return item.dirty || item.id === 0;
  8. })
  9.  
  10. // collect deleted rows
  11. $.each(grid.dataSource._destroyed, function (index, item) {
  12. item.IsDeleted = true;
  13. items.push(item);
  14. })
  15.  
  16. $.ajax({
  17. type: "POST",
  18. data: items,
  19. url: "save",
  20. contentType: "application/json; charset=utf-8",
  21. processData: true,
  22. cache: false,
  23. })
  24. .done(function (response, textStatus, jqXHR) {
  25. // do something
  26. })
  27. .fail(function (jqXHR, textStatus, errorThrown) {
  28. // How do i inform datasource or grid about error
  29.  
  30. })
  31.  
  32. })
Add Comment
Please, Sign In to add comment