Hide Row

Hide Row

andreas.gebetsroither@sps.atandreas.gebetsroither@sps.at Posts: 6Questions: 4Answers: 0

How can i hide all rows of the table which where the date is smaller than the current date?
I tried this:

    createdRow: function( row, data, type ) {
        if (data[2] < '09.04.2020') {
            $(row).hide();
        }
    },

data[2] should be the date but nothing happens.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,342Questions: 26Answers: 4,776
    Answer ✓

    Datatables doesn't support hiding rows this way. Using jQuery hide() manipulates the DOM table which Datatables won't know about. This will affect the row display. For example if the table displays 10 rows and you hide() 5 of them then only 5 rows will be displayed.

    The best way to do this is to implement a range search as shown in this example. This thread has an example of a date range search. You can adapt it to simply filter rows based on the current date instead of an input. The Search Plugin will automatically run every time the table draws.

    Kevin

This discussion has been closed.