Change default order column with checkbox - datatable js

119 views Asked by At

Is there a way of changing the sort column in datatable by checking a checkbox ? When I click a "search button" to get data from database, I want the sort to be whatever the checkboxes as checked, like 1 and 3 or only 2 or only 3 and so on.

example

when i check the box "Nome do Paciente", i want the column "Nome do Paciente" to be the deafult sort for that search.

1

There are 1 answers

0
ferchoman09 On BEST ANSWER

Documentation OrderBy Filter

The OrderBy Filter can have a collection with the names of columns that you want to order. When you change some check, you can add or remove an element on this array from your controller.

Remmember use this variable in your template. Like this:

<tr ng-repeat="row in rows | orderBy:variableOrderBy">
</tr>

The variable variableOrderBy has the collection of columns.