0

Sorry I am new here and don't know how to ask queries.

I have a salary table. there is a column by which users can see the data of employees in month wise. I have used the example in https://www.datatables.net/examples/api/multi_filter_select.html. But in the footer portion, it is showing the month name in alphabetical order, but I want it in January, February..... December. I have uploaded the test cases here. Please check

http://live.datatables.net/rowufiru/1/

the output image is My HTML code is

<table id="example1" class="display table table-bordered">
  <thead>
    <th>Name</th>
    <th data-field="start_date" data-sortable="true" data-footer-formatter="amountFormatter">Month</th>
    <th>Year</th>
    <th>Total salary</th>
  </thead>
  <tbody id="employee_data">
    <tr>
      <td>Akash</td>
      <td>December</td>
      <td>2020</td>
      <td>500</td>
    </tr>
    <tr>
      <td>Sumit</td>
      <td>March</td>
      <td>2020</td>
      <td>600</td>
    </tr>
    <tr>
      <td>Akash</td>
      <td>January</td>
      <td>2020</td>
      <td>500</td>
    </tr>
    <tr>
      <td>Sumit</td>
      <td>April</td>
      <td>2020</td>
      <td>500</td>
    </tr>
    <tr>
      <td>Sumit</td>
      <td>May</td>
      <td>2020</td>
      <td>500</td>
    </tr>
    <tr>
      <td>Akash</td>
      <td>February</td>
      <td>2020</td>
      <td>500</td>
    </tr>
    <tr>
      <td>Sumit</td>
      <td>January</td>
      <td>2020</td>
      <td>500</td>
    </tr>
    <tr>
      <td>Akash</td>
      <td>October</td>
      <td>2020</td>
      <td>500</td>
    </tr>
    <?php
                    }
                  ?>
  </tbody>
  <tfoot>
    <tr>
      <th>Name</th>
      <th>Month</th>
      <th>Year</th>
      <th>Total salary</th>
      <th></th>
    </tr>
  </tfoot>
</table>
Vivek Jain
  • 2,730
  • 6
  • 12
  • 27
  • Have you tried to sort the data ? can you share your js as well? – AbbasEbadian Sep 01 '20 at 06:20
  • Take a look here: https://stackoverflow.com/questions/39265301/sort-by-name-in-alphabetical-order-not-working-in-data-table – Grzegorz Miśkiewicz Sep 01 '20 at 08:39
  • My js is as follows: – Virgin Child Sep 01 '20 at 12:56
  • My js file is $(function () { $('#example1').DataTable( { initComplete: function () { this.api().columns([0, 1, 2, 3]).every( function () { var column = this; var select = $('') .appendTo( $(column.footer()).empty() ) .on( 'change', function () { var val = $.fn.dataTable.util.escapeRegex( $(this).val() ); column .search( val ? '^'+val+'$' : '', true, false ) .draw(); } ); column.data().unique().sort().each( function ( d, j ) { select.append( '' ) } ); } ) } } ); }) – Virgin Child Sep 01 '20 at 12:59

0 Answers0