datatables.init.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. 'use strict';
  2. $(document).ready(function () {
  3. var responsiveHelper = undefined;
  4. var breakpointDefinition = {
  5. tablet: 1024,
  6. phone : 480
  7. };
  8. var tableElement = $('#SampleDT');
  9. tableElement.dataTable({
  10. "autoWidth" : false,
  11. preDrawCallback: function () {
  12. // Initialize the responsive datatables helper once.
  13. if (!responsiveHelper) {
  14. responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition);
  15. }
  16. },
  17. rowCallback : function (nRow) {
  18. responsiveHelper.createExpandIcon(nRow);
  19. },
  20. drawCallback : function (oSettings) {
  21. responsiveHelper.respond();
  22. }
  23. });
  24. });
  25. // Products list example
  26. $(document).ready(function () {
  27. var responsiveHelper = undefined;
  28. var breakpointDefinition = {
  29. tablet: 1024,
  30. phone : 480
  31. };
  32. var tableElement = $('#products');
  33. tableElement.dataTable({
  34. //"paginationType": 'bootstrap',
  35. "language" : {
  36. 'lengthMenu': "_MENU_ products per page",
  37. //"zeroRecords": "Nothing found - sorry",
  38. //"info": "Showing page _PAGE_ of _PAGES_",
  39. //"infoEmpty": "No records available",
  40. //"infoFiltered": "(filtered from _MAX_ total records)"
  41. },
  42. // disable sorting on the checkbox column
  43. "columnDefs" : [
  44. {
  45. 'targets' : [ 0 ], // Column number which needs to be modified
  46. 'sortable': false, // Column is not sortable
  47. // Custom render function - add checkbox
  48. 'render' : function (data, type) {
  49. return '<label><input type="checkbox" class="tc"><span class="labels"></span></label>';
  50. },
  51. 'class' : 'col-small center' // Optional - class to be applied to this table cell
  52. },
  53. {
  54. 'targets': [ 8 ], // Column number which needs to be modified
  55. 'sortable': false, // Column is not sortable
  56. 'class' : 'col-medium center' // Optional - class to be applied to this table cell
  57. }
  58. ],
  59. "order": [[ 2, "desc" ]], // Default ordering (sorting)
  60. "autoWidth" : false,
  61. //"ajax" : './arrays.txt',
  62. // for more option please see http://datatables.net/examples/index
  63. preDrawCallback: function () {
  64. // Initialize the responsive datatables helper once.
  65. if (!responsiveHelper) {
  66. responsiveHelper = new ResponsiveDatatablesHelper(tableElement, breakpointDefinition);
  67. }
  68. },
  69. rowCallback : function (nRow) {
  70. responsiveHelper.createExpandIcon(nRow);
  71. },
  72. drawCallback : function (oSettings) {
  73. responsiveHelper.respond();
  74. }
  75. });
  76. });