Add a fixed, unsortable row every N rows.
Add a fixed, unsortable row every N rows.
Hello all,
I'm using a Wordpress plugin that uses DataTables, and I want to know if there's a way of adding a fixed/unsortable row every N rows in a table.
A little like this: https://datatables.net/examples/advanced_init/row_grouping.html but the "header" row in this case wouldn't move, while everything else could be sorted normally, without being grouped. If necessary I can add a <tr class="no-sort"> every N rows in my data from the backend, though from my Googling this doesn't seem like the correct way to go about it.
This is the code I'm working with: https://plugins.trac.wordpress.org/browser/posts-data-table/tags/1.0.4/assets/js/posts-data-table.js
I don't have the slightest clue when it comes to JavaScript, so any help is welcome, even if it's something obvious.
This question has an accepted answers - jump to answer
Answers
Sort of. You can use
orderFixed
to apply fixed ordering to the table, forcing DataTables to always sort by the given column first, before then sorting by the user defined column.Example (same as the example link, just with
orderFixed
defined).Allan
Hi Allan,
Thank you for your suggestion, but it didn't quite do what I wanted. I've figured out how to do it, posting here for posterity.
And
Probably pretty crude, but gets the job done.