table-data.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. $(function(e) {
  2. "use strict";
  3. //______Basic Data Table
  4. $('#basic-datatable').DataTable({
  5. language: {
  6. searchPlaceholder: '搜索...',
  7. sSearch: '',
  8. },
  9. });
  10. //______Basic Data Table
  11. $('#responsive-datatable').DataTable({
  12. language: {
  13. searchPlaceholder: '搜索...',
  14. scrollX: "100%",
  15. sSearch: '',
  16. }
  17. });
  18. //______File-Export Data Table
  19. var table = $('#file-datatable').DataTable({
  20. buttons: ['copy', 'excel', 'pdf', 'colvis'],
  21. language: {
  22. searchPlaceholder: '搜索...',
  23. scrollX: "100%",
  24. sSearch: '',
  25. }
  26. });
  27. table.buttons().container()
  28. .appendTo('#file-datatable_wrapper .col-md-6:eq(0)');
  29. //______Delete Data Table
  30. var table = $('#delete-datatable').DataTable({
  31. language: {
  32. searchPlaceholder: 'Search...',
  33. sSearch: '',
  34. }
  35. });
  36. $('#delete-datatable tbody').on('click', 'tr', function() {
  37. if ($(this).hasClass('selected')) {
  38. $(this).removeClass('selected');
  39. } else {
  40. table.$('tr.selected').removeClass('selected');
  41. $(this).addClass('selected');
  42. }
  43. });
  44. $('#button').on('click', function() {
  45. table.row('.selected').remove().draw(false);
  46. });
  47. $('#example3').DataTable( {
  48. responsive: {
  49. details: {
  50. display: $.fn.dataTable.Responsive.display.modal( {
  51. header: function ( row ) {
  52. var data = row.data();
  53. return 'Details for '+data[0]+' '+data[1];
  54. }
  55. } ),
  56. renderer: $.fn.dataTable.Responsive.renderer.tableAll( {
  57. tableClass: 'table'
  58. } )
  59. }
  60. }
  61. } );
  62. $('#example2').DataTable({
  63. responsive: true,
  64. language: {
  65. searchPlaceholder: '搜索...',
  66. sSearch: '',
  67. lengthMenu: '_MENU_ items/page',
  68. }
  69. });
  70. //______Select2
  71. $('.select2').select2({
  72. minimumResultsForSearch: Infinity
  73. });
  74. });