No sorting by default...

No sorting by default...

huyschihuyschi Posts: 17Questions: 4Answers: 1

Hi,
As far as I understand, the ordering (sorting) and search is available by default, so when the end user e.g. clicks a column header, the column gets sorted (either asc or desc).
Unfortunately it is not working, but the search function does.
Here is an extract of the code in question:
```

<% @events.each do |event| %> <% end %>
Name Event type definition Activities Location Trainer From - To Attendees Status Office Vouchers
<%= event.name %> <%= event.event_type_definition %> Activities Location Trainer From - To Attendees Status Office Vouchers <%= link_to 'Show', event %> <%= link_to 'Edit', edit_event_path(event) %> <%= link_to 'Destroy', event, method: :delete, data: { confirm: 'Are you sure?' } %>
$(document).ready( function() { $('#dashboard').DataTable({ // responsive: true, // autoWidth: true, // dom: '<"datatable-header"fl><"datatable-scroll"t><"datatable-footer"ip>', // language: { // search: 'Filter: _INPUT_', // lengthMenu: 'Show: _MENU_', // paginate: { 'first': 'First', 'last': 'Last', 'next': '→', 'previous': '←' } // }, }); // $('#dashboard').footable({ // }); } );

```

I would very much appreciate any help on this. Thank you.

Regards,
Nissim

This question has an accepted answers - jump to answer

Answers

  • David@QuantumDavid@Quantum Posts: 36Questions: 4Answers: 2
    edited October 2019 Answer ✓

    @huyschi , please refer to the documentation for ordering. I assume

    $('#example').dataTable( {
      "ordering": true
    } );
    

    Is what you're looking for. You may have to set this value to force it.

    Kind regards,
    David

  • huyschihuyschi Posts: 17Questions: 4Answers: 1

    Hi DAvid,

    Thank you for your quick response.

    I'll try it, eventhough the documantation says, it is by default activated.

    Reagds,

    Nissim

  • allanallan Posts: 63,192Questions: 1Answers: 10,412 Site admin

    Hi Nissim,

    Thanks for your question. As noted in the forum rules, please post a link to a running test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Allan

  • huyschihuyschi Posts: 17Questions: 4Answers: 1

    Hi David,
    Yes, your suggestion works. Thank you.

    Regards,

    Nissim

  • David@QuantumDavid@Quantum Posts: 36Questions: 4Answers: 2

    @huyschi , Awesome, glad I could help, Nissim! Remember to accept the answer so anyone visiting this question can find it easily :wink:

    Regards,
    David

This discussion has been closed.