Header templating
Header templating
I'd like to create a complex header for my table. Something along the lines of this:
[code]
<!-- column groupings -->
Employee
Compensation
<!-- column headers -->
Name
Email
Title
Salary
<!-- column summaries -->
$50,000
<!-- table rows -->
[/code]
The table header detection algorithm attaches sort classes to the wrong TH elements. What is the best way to bypass this functionality? I would love to specify which row contains unique TH elements via a JQuery selector. (ie. tr.header-row) How might I accomplish this?
[code]
<!-- column groupings -->
Employee
Compensation
<!-- column headers -->
Name
Title
Salary
<!-- column summaries -->
$50,000
<!-- table rows -->
[/code]
The table header detection algorithm attaches sort classes to the wrong TH elements. What is the best way to bypass this functionality? I would love to specify which row contains unique TH elements via a JQuery selector. (ie. tr.header-row) How might I accomplish this?
This discussion has been closed.
Replies
You can have as many rows as you want in a header - just put the second row in the first header and remove the second header. Also the bSortCellsTop option can be used to control which row int he header the sort handlers are applied to.
Allan
Unfortunately there isn't a built in way of doing that in DataTables at the moment. You would need to either modify DataTables or use the fnSortListener API method to add the sort listener to the columns you want.
Allan
-Jeff
This is the function where DataTables does its header detection: https://github.com/DataTables/DataTablesSrc/blob/master/js/core/core.draw.js#L703 - bSortCellsTop is the variable that changes the behaviour. I guess that could be changed to a selector, although it could introduce a fair amount of code, and I'm already 0.5K over "limit" for 1.10.
Allan