table-managed.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. var TableManaged = function () {
  2. return {
  3. //main function to initiate the module
  4. init: function () {
  5. if (!jQuery().dataTable) {
  6. return;
  7. }
  8. // begin first table
  9. $('#sample_1').dataTable({
  10. "aoColumns": [
  11. { "bSortable": false },
  12. null,
  13. { "bSortable": false },
  14. null,
  15. { "bSortable": false },
  16. { "bSortable": false }
  17. ],
  18. "aLengthMenu": [
  19. [5, 15, 20, -1],
  20. [5, 15, 20, "All"] // change per page values here
  21. ],
  22. // set the initial value
  23. "iDisplayLength": 5,
  24. "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
  25. "sPaginationType": "bootstrap",
  26. "oLanguage": {
  27. "sLengthMenu": "_MENU_ records per page",
  28. "oPaginate": {
  29. "sPrevious": "Prev",
  30. "sNext": "Next"
  31. }
  32. },
  33. "aoColumnDefs": [{
  34. 'bSortable': false,
  35. 'aTargets': [0]
  36. }
  37. ]
  38. });
  39. jQuery('#sample_1 .group-checkable').change(function () {
  40. var set = jQuery(this).attr("data-set");
  41. var checked = jQuery(this).is(":checked");
  42. jQuery(set).each(function () {
  43. if (checked) {
  44. $(this).attr("checked", true);
  45. } else {
  46. $(this).attr("checked", false);
  47. }
  48. });
  49. jQuery.uniform.update(set);
  50. });
  51. jQuery('#sample_1_wrapper .dataTables_filter input').addClass("m-wrap medium"); // modify table search input
  52. jQuery('#sample_1_wrapper .dataTables_length select').addClass("m-wrap small"); // modify table per page dropdown
  53. //jQuery('#sample_1_wrapper .dataTables_length select').select2(); // initialzie select2 dropdown
  54. // begin second table
  55. $('#sample_2').dataTable({
  56. "aLengthMenu": [
  57. [5, 15, 20, -1],
  58. [5, 15, 20, "All"] // change per page values here
  59. ],
  60. // set the initial value
  61. "iDisplayLength": 5,
  62. "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
  63. "sPaginationType": "bootstrap",
  64. "oLanguage": {
  65. "sLengthMenu": "_MENU_ per page",
  66. "oPaginate": {
  67. "sPrevious": "Prev",
  68. "sNext": "Next"
  69. }
  70. },
  71. "aoColumnDefs": [{
  72. 'bSortable': false,
  73. 'aTargets': [0]
  74. }
  75. ]
  76. });
  77. jQuery('#sample_2 .group-checkable').change(function () {
  78. var set = jQuery(this).attr("data-set");
  79. var checked = jQuery(this).is(":checked");
  80. jQuery(set).each(function () {
  81. if (checked) {
  82. $(this).attr("checked", true);
  83. } else {
  84. $(this).attr("checked", false);
  85. }
  86. });
  87. jQuery.uniform.update(set);
  88. });
  89. jQuery('#sample_2_wrapper .dataTables_filter input').addClass("m-wrap small"); // modify table search input
  90. jQuery('#sample_2_wrapper .dataTables_length select').addClass("m-wrap small"); // modify table per page dropdown
  91. jQuery('#sample_2_wrapper .dataTables_length select').select2(); // initialzie select2 dropdown
  92. // begin: third table
  93. $('#sample_3').dataTable({
  94. "aLengthMenu": [
  95. [5, 15, 20, -1],
  96. [5, 15, 20, "All"] // change per page values here
  97. ],
  98. // set the initial value
  99. "iDisplayLength": 5,
  100. "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
  101. "sPaginationType": "bootstrap",
  102. "oLanguage": {
  103. "sLengthMenu": "_MENU_ per page",
  104. "oPaginate": {
  105. "sPrevious": "Prev",
  106. "sNext": "Next"
  107. }
  108. },
  109. "aoColumnDefs": [{
  110. 'bSortable': false,
  111. 'aTargets': [0]
  112. }
  113. ]
  114. });
  115. jQuery('#sample_3 .group-checkable').change(function () {
  116. var set = jQuery(this).attr("data-set");
  117. var checked = jQuery(this).is(":checked");
  118. jQuery(set).each(function () {
  119. if (checked) {
  120. $(this).attr("checked", true);
  121. } else {
  122. $(this).attr("checked", false);
  123. }
  124. });
  125. jQuery.uniform.update(set);
  126. });
  127. jQuery('#sample_3_wrapper .dataTables_filter input').addClass("m-wrap small"); // modify table search input
  128. jQuery('#sample_3_wrapper .dataTables_length select').addClass("m-wrap small"); // modify table per page dropdown
  129. jQuery('#sample_3_wrapper .dataTables_length select').select2(); // initialzie select2 dropdown
  130. }
  131. };
  132. }();