Advertisement
Guest User

Untitled

a guest
Jan 19th, 2020
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. <script>
  2. $(document).ready(function() {
  3.  
  4. //$.fn.dataTable.render.moment("M/D/YYYY");
  5. var editor = new $.fn.dataTable.Editor({
  6. table: "#example",
  7. fields: [
  8. {
  9. label: 'Name:',
  10. name: 'name'
  11. },
  12. {
  13. label: 'Position:',
  14. name: 'position'
  15. },
  16. {
  17. label: 'Office:',
  18. name: 'office',
  19. type: 'select',
  20. options: ['Tokyo', 'London']
  21. }
  22. ]
  23. });
  24.  
  25. $("#example").DataTable({
  26. dom: "Bfrtip",
  27. processing: true,
  28. serverSide: true,
  29. columns: [
  30. { data: 'name' },
  31. { data: 'position' },
  32. { data: 'office' },
  33. ],
  34. select: true,
  35. buttons: [
  36. { extend: "create", editor: editor },
  37. { extend: "edit", editor: editor },
  38. { extend: "remove", editor: editor }
  39. ],
  40. ajax: {
  41. url: 'test_example.php',
  42. type: 'post'
  43. },
  44. });
  45.  
  46. $('#example').on('click', 'tbody td:not(:first-child, :nth-child(2))', function(e) {
  47. editor.inline(this);
  48. });
  49.  
  50. editor.field('office').input().on('change', function(e, data) {
  51. if (!data || !data.editor) {
  52. editor.submit();
  53. }
  54. });
  55.  
  56. });
  57.  
  58.  
  59. </script>
  60.  
  61.  
  62. <body>
  63.  
  64. <table id="example" class="display" width="100%" cellspacing="0">
  65. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement