Can we make a row in datatable get excluded in sorting over every coloumn sort?

Can we make a row in datatable get excluded in sorting over every coloumn sort?

chandupranaychandupranay Posts: 1Questions: 1Answers: 0

How to make a specific row exclude in table in-built sort option by clicking over the any column header.
Let us say the rows which are not to be included are checked in checkboxes in first column. and to visualize the sorting rows clearly,make the checked rows goes bottom of the table.

In that attached picture the sorting should happen only to the top 3 rows . and the last checked row should stay at bottom until it is unchecked regardless of any column sort we choose.

Answers

  • colincolin Posts: 15,236Questions: 1Answers: 2,598

    Possibly! There's an Absolute plugin that keeps rows at the top or the bottom of the table. This is designed to be used with fixed values, but can you customise it like this example from this thread. Here, it uses a hidden column to store the first letter, which the plugin matches against:

        var onTop = $.fn.dataTable.absoluteOrder([{
            value: 'L',
            position: 'top'
        }]);
    

    You could do something similar with the checkbox. It can't use the checkbox itself as it's not a fixed value, but whenever it's checked, you could have an event handler that updates a hidden column (cell().data()).

    Hope that helps, let us know how you get on,

    Colin

Sign In or Register to comment.