deliveryDetails.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <table id="example" class="table display table-striped table-bordered table-hover table-sm" cellspacing="0" width="100%">
  2. <thead>
  3. <tr>
  4. <th></th>
  5. <th>Action</th>
  6. <th>Message</th>
  7. <th>id</th>
  8. <th>Tank</th>
  9. <th>Status</th>
  10. <th>Start</th>
  11. <th>End</th>
  12. </tr>
  13. </thead>
  14. <tfoot>
  15. <tr>
  16. <th></th>
  17. <th>Action</th>
  18. <th>Message</th>
  19. <th>id</th>
  20. <th>Tank</th>
  21. <th>Status</th>
  22. </tr>
  23. </tfoot>
  24. </table>
  25. <script type="text/javascript">
  26. /* Formatting function for row details - modify as you need */
  27. function format ( d ) {
  28. // `d` is the original data object for the row
  29. return '<table id="example" class="table table-bordered table-sm" cellspacing="0" width="100%" style="background-color:#3F51B5;color:white;">'+
  30. '<tr>'+
  31. '<td>Product:</td>'+
  32. '<td>'+d.Product+'</td>'+
  33. '</tr>'+
  34. '<tr>'+
  35. '<td>Supplier Id:</td>'+
  36. '<td>'+d.SupplierId+'</td>'+
  37. '</tr>'+
  38. '<tr>'+
  39. '<td>Supplier Name:</td>'+
  40. '<td>'+d.SupplierName+'</td>'+
  41. '</tr>'+
  42. '<tr>'+
  43. '<td>Delivery Car Number:</td>'+
  44. '<td>'+d.DeliveryCarNumber+'</td>'+
  45. '</tr>'+
  46. '<tr>'+
  47. '<td>OrderPrice:</td>'+
  48. '<td>'+d.OrderPrice+'</td>'+
  49. '</tr>'+
  50. '<tr>'+
  51. '<td>OrderVolume:</td>'+
  52. '<td>'+d.OrderVolume+'</td>'+
  53. '</tr>'+
  54. '<tr>'+
  55. '<td>DeliverVolume:</td>'+
  56. '<td>'+d.DeliverVolume+'</td>'+
  57. '</tr>'+
  58. '<tr>'+
  59. '<td>FuelPoints:</td>'+
  60. '<td>'+d.FuelPoints+'</td>'+
  61. '</tr>'+
  62. '<tr>'+
  63. '<td>TankGroup:</td>'+
  64. '<td>'+d.TankGroup+'</td>'+
  65. '</tr>'+
  66. '<tr>'+
  67. '<td>Tank id</td>'+
  68. '<td>Start Volume</td>'+
  69. '<td>End Volume</td>'+
  70. '<td>Input Volume</td>'+
  71. '</tr>'+
  72. '<tr>'+
  73. '<td>Fp id</td>'+
  74. '<td>Start Volume</td>'+
  75. '<td>End Volume</td>'+
  76. '<td>Output Volume</td>'+
  77. '</tr>'+
  78. '</table>';
  79. }
  80. // '<table>'+
  81. // '<tr>'+
  82. // '<th>Tank Id</th>'+
  83. // '<th>Start Volume</th>'+
  84. // '<th>End Volume</th>'+
  85. // '<th>Input Volume</th>'+
  86. // '<tr>'+
  87. // '</table>'
  88. $(document).ready(function() {
  89. var table = $('#example').DataTable( {
  90. "ajax": "api/v1/Deliveries/deliveryDetails.txt",
  91. "columns": [
  92. {
  93. "className": 'details-control',
  94. "orderable": false,
  95. "data": null,
  96. "defaultContent": ''
  97. },
  98. { "data": "Action" },
  99. { "data": "Message" },
  100. { "data": "Id" },
  101. { "data": "Tank" },
  102. { "data": "Status" },
  103. { "data": "Start" },
  104. { "data": "End" },
  105. ],
  106. "order": [[1, 'asc']]
  107. } );
  108. // Add event listener for opening and closing details
  109. $('#example tbody').on('click', 'td.details-control', function () {
  110. var tr = $(this).closest('tr');
  111. var row = table.row( tr );
  112. if ( row.child.isShown() ) {
  113. // This row is already open - close it
  114. row.child.hide();
  115. tr.removeClass('shown');
  116. }
  117. else {
  118. // Open this row
  119. row.child( format(row.data()) ).show();
  120. tr.addClass('shown');
  121. }
  122. } );
  123. } );
  124. </script>