Option for pagination to neglect hidden rows?

Option for pagination to neglect hidden rows?

dvnlglsdvnlgls Posts: 5Questions: 0Answers: 0
edited February 2013 in Feature requests
It would be nice to have the option of pagination to ignore hidden rows. Currently if I have a table of 100 rows, of which 50 are hidden and I display 10 rows/page, there will be 10 pages. If this feature is present I'd be seeing only 5 pages.

Example scenario. Consider a table that displays many records. Each record may contain a class: "active" or "inactive". By default I want to show only rows with "active" class. So I hide the inactive ones and apply datatable. Now upon a button click, I want to hide the active rows and show inactive rows. I'd use JS to achieve that and apply datatable again.

I've a workaround as of now but if many people want such a feature, do consider. Thanks.

Replies

  • allanallan Posts: 63,573Questions: 1Answers: 10,483 Site admin
    This is not going to be added to be added to DataTables core as there is already the ability to remove rows using filtering which can easily be extended to provide this ability ( http://datatables.net/development/filtering - row based filtering ).

    Having a built-in check on display:none on every single row would be horribly slow since DataTables would need to check what the display status of every row is. If you are prepared to take that this, then a filtering plug-in, as I mentioned above, will work just fine.

    Allan
  • dvnlglsdvnlgls Posts: 5Questions: 0Answers: 0
    ah, thanks for clearing this up. I'm fairly new to datatables and will dive into filtering more. awesome community :)
  • dvnlglsdvnlgls Posts: 5Questions: 0Answers: 0
    @allan I was able to achieve the desired result by using range filtering as you suggested and it works well. Also it's much faster. Just tweaked this example to make it work: http://datatables.net/release-datatables/examples/plug-ins/range_filtering.html Thanks again mate.
  • allanallan Posts: 63,573Questions: 1Answers: 10,483 Site admin
    Good stuff. Glad to hear this works for you.

    Allan
This discussion has been closed.