Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1816

How to preserve/pass-through html th attributes to DataTable initialization?

$
0
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 <th/> 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:
     <thead>
                <tr>
                    <th class="">Test Data</th>
                    <th class="text-center">Time</th>
                    <th class="text-center sorting_asc">Rank</th>
                    <th class="text-center">Coefficient</th>
                    <th>Forecast</th>
                </tr>
     </thead>

Here is the initialization code I use:
$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 }
            ]
        } );

How can I honor the existing th class attribute when initializing the table?

Viewing all articles
Browse latest Browse all 1816

Trending Articles