wansyahi1

Javascript

Dec 14th, 2019
90
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2. $(document).ready(function(){
  3.  
  4. fill_datatable();
  5.  
  6. function fill_datatable( dataGender = '')
  7. {
  8. var dataTable = $('#table_data').DataTable({
  9. processing: true,
  10. serverSide: true,
  11. "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
  12. ajax:{
  13. url:'/filter-result',
  14. data:{dataGender:dataGender,ethnicity:ethnicity,area:area,state:state,namaDUN:namaDUN}
  15. },
  16.  
  17. columns: [
  18. {
  19. data:'id',
  20. name:'id'
  21. },
  22. {
  23. data:'First_name',
  24. name:'First_name'
  25. },
  26. {
  27. data:'Last_name',
  28. name:'Last_name'
  29. },
  30. {
  31. data:'Umur',
  32. name:'Umur'
  33. },
  34. {
  35. data:'Phonenum',
  36. name:'Phonenum'
  37. },
  38. {
  39. data:'TarikhLahir',
  40. name:'TarikhLahir'
  41. },
  42. {
  43. data:'Negeri',
  44. name:'Negeri'
  45. },
  46. {
  47. data:'Country',
  48. name:'Country'
  49. },
  50. {
  51. data:'postcode',
  52. name:'postcode'
  53. },
  54. {
  55. data:'Ct',
  56. name:'Ct'
  57. },
  58. {
  59. data:'Jantina',
  60. name:'Jantina'
  61. }
  62.  
  63. ]
  64.  
  65. });
  66.  
  67. }
  68.  
  69.  
  70. $('#filter').click(function(){
  71. var table = $('#table_data').DataTable();
  72. var age = $('#age').val();
  73. var dataGender = $('#dataGender').val();
  74. var ethnicity = $('#ethnicity').val();
  75. var area = $('#area').val();
  76. var state = $('#state').val();
  77. var namaDUN = $('#namaDUN').val();
  78.  
  79.  
  80. if( $.fn.DataTable.isDataTable('#table_data')){
  81. table.destroy();
  82. $('#table_data').empty();
  83. alert('haha')
  84. var dataTable = $('#table_data').DataTable({
  85. processing: true,
  86. serverSide: true,
  87. "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
  88. ajax:{
  89. url:'/filter-result',
  90. data:{dataGender:dataGender,ethnicity:ethnicity,area:area,state:state,namaDUN:namaDUN}
  91. },
  92.  
  93. columns: [
  94. {
  95. data:'id',
  96. name:'id'
  97. },
  98. {
  99. data:'First_name',
  100. name:'First_name'
  101. },
  102. {
  103. data:'Last_name',
  104. name:'Last_name'
  105. },
  106. {
  107. data:'Umur',
  108. name:'Umur'
  109. },
  110. {
  111. data:'Phonenum',
  112. name:'Phonenum'
  113. },
  114. {
  115. data:'TarikhLahir',
  116. name:'TarikhLahir'
  117. },
  118. {
  119. data:'Negeri',
  120. name:'Negeri'
  121. },
  122. {
  123. data:'Country',
  124. name:'Country'
  125. },
  126. {
  127. data:'postcode',
  128. name:'postcode'
  129. },
  130. {
  131. data:'Ct',
  132. name:'Ct'
  133. },
  134. {
  135. data:'Jantina',
  136. name:'Jantina'
  137. }
  138.  
  139. ]
  140.  
  141. });
  142.  
  143.  
  144. }
  145. });
RAW Paste Data