How to preserve/pass-through html th attributes to DataTable initialization?
How to preserve/pass-through html th attributes to DataTable initialization?
tday
Posts: 6Questions: 0Answers: 0
This is a great progressive enhancement tool - congratulations!
I am saving the column sort settings (on the server) of each column (the class "sorting_asc" or "sorting_desc") from the element. When recreating the table, I re-apply the class attribute using a handlebar template. The problem I encounter is during DataTable initialization which sets other defaults. The initialization seems to override the th class attribute that is in the html DOM.
Here is the table header:
[code]
Test Data
Time
Rank
Coefficient
Forecast
[/code]
Here is the initialization code I use:
[code]
$forecastContainer.find('table.test-data').dataTable( {
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
//"aaSorting": [[ 2, "asc" ]], //sorting configuration set in html template by specifying class attribute on each th
"aoColumns": [
/* Test Data */ null,
/* Time Shift */ null,
/* Forecast Date */ null,
/* Confidence Interval */ null,
/* Slider */ {
"bSearchable": false,
"bSortable": false },
/* Forecast */ {
"bSearchable": false,
"bSortable": false }
]
} );
[/code]
How can I honor the existing th class attribute when initializing the table?
I am saving the column sort settings (on the server) of each column (the class "sorting_asc" or "sorting_desc") from the element. When recreating the table, I re-apply the class attribute using a handlebar template. The problem I encounter is during DataTable initialization which sets other defaults. The initialization seems to override the th class attribute that is in the html DOM.
Here is the table header:
[code]
Test Data
Time
Rank
Coefficient
Forecast
[/code]
Here is the initialization code I use:
[code]
$forecastContainer.find('table.test-data').dataTable( {
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bSort": true,
"bInfo": false,
"bAutoWidth": false,
//"aaSorting": [[ 2, "asc" ]], //sorting configuration set in html template by specifying class attribute on each th
"aoColumns": [
/* Test Data */ null,
/* Time Shift */ null,
/* Forecast Date */ null,
/* Confidence Interval */ null,
/* Slider */ {
"bSearchable": false,
"bSortable": false },
/* Forecast */ {
"bSearchable": false,
"bSortable": false }
]
} );
[/code]
How can I honor the existing th class attribute when initializing the table?
This discussion has been closed.
Replies
Or possibly bStateSave might be of some use.
Allan
This confirms my search through the documentation.
Kind Regards