data-table.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //[Data Table Javascript]
  2. //Project: Riday Admin - Responsive Admin Template
  3. //Primary use: Used only for the Data Table
  4. $(function () {
  5. "use strict";
  6. $('#example1').DataTable();
  7. $('#example2').DataTable({
  8. 'paging' : true,
  9. 'lengthChange': false,
  10. 'searching' : false,
  11. 'ordering' : true,
  12. 'info' : true,
  13. 'autoWidth' : false
  14. });
  15. $('#example').DataTable( {
  16. dom: 'Bfrtip',
  17. buttons: [
  18. 'copy', 'csv', 'excel', 'pdf', 'print'
  19. ]
  20. } );
  21. $('#tickets').DataTable({
  22. 'paging' : true,
  23. 'lengthChange': true,
  24. 'searching' : true,
  25. 'ordering' : true,
  26. 'info' : true,
  27. 'autoWidth' : false,
  28. });
  29. $('#productorder').DataTable({
  30. 'paging' : true,
  31. 'lengthChange': true,
  32. 'searching' : true,
  33. 'ordering' : true,
  34. 'info' : true,
  35. 'autoWidth' : false,
  36. });
  37. $('#complex_header').DataTable();
  38. //--------Individual column searching
  39. // Setup - add a text input to each footer cell
  40. $('#example5 tfoot th').each( function () {
  41. var title = $(this).text();
  42. $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
  43. } );
  44. // DataTable
  45. var table = $('#example5').DataTable();
  46. // Apply the search
  47. table.columns().every( function () {
  48. var that = this;
  49. $( 'input', this.footer() ).on( 'keyup change', function () {
  50. if ( that.search() !== this.value ) {
  51. that
  52. .search( this.value )
  53. .draw();
  54. }
  55. } );
  56. } );
  57. //---------------Form inputs
  58. var table = $('#example6').DataTable();
  59. $('button').click( function() {
  60. var data = table.$('input, select').serialize();
  61. alert(
  62. "The following data would have been submitted to the server: \n\n"+
  63. data.substr( 0, 120 )+'...'
  64. );
  65. return false;
  66. } );
  67. }); // End of use strict