Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. function EnableDragAndDropForGrid() {
  2. let grid = $('#grid').data('kendoGrid');
  3. console.log(grid)
  4. grid.lockedTable.kendoSortable({
  5. filter: ">tbody >tr",
  6. hint: function(element) {
  7. var unlockedPortion = grid.table.find("tr[data-uid=" + element.data("uid") + "]").children();
  8.  
  9. let table = $('<table style="width: 600px;" class="k-grid k-widget"></table>'),
  10. hint;
  11.  
  12. table.append(element.clone().append(unlockedPortion));
  13. table.css("opacity", 0.7);
  14.  
  15. return table;
  16. },
  17. cursor: "move",
  18. placeholder: function(element) {
  19. return $('<tr colspan="4" class="placeholder"></tr>');
  20. },
  21. change: function(e) {
  22. let skip = grid.dataSource.skip(),
  23. oldIndex = e.oldIndex + skip,
  24. newIndex = e.newIndex + skip,
  25. data = grid.dataSource.data(),
  26. dataItem = grid.dataSource.getByUid(e.item.data("uid"));
  27.  
  28. grid.dataSource.remove(dataItem);
  29. grid.dataSource.insert(newIndex, dataItem);
  30.  
  31. }
  32. });
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement