Data Type seems to be detected from the data-order rather than the actual data
Data Type seems to be detected from the data-order rather than the actual data
I have a row like this:
<tr>
<th>Information</th>
</tr>
<tr>
<td data-order="1699675200" class="dt-type-numeric sorting_1"><a href="page?id=123">Text</a>
</td>
</tr>.....
When the table is rendered it gets the 'dt-type-numeric sorting_1' class which makes it right-justified. Since it is visible text, I want it to be left-justified, even though the data to sort on is numeric.
The workaround I found is to simply add a letter to look like this: data-order="x1699675200", but that may mess up the sort. Is there a better way?
Answers
One option is to remove or change the class for the numeric type using
DataTable.type(). This will affect all numeric columns.Another option is to remove the class from specific columns using
column().header()andcolumn().nodes()ininitComplete.Kevin
Another option is to add another class to the column (
columns.className) and use that to force the text alignment as you need.Multiple data types for a column is something I've considered before, but I'm concerned about the performance impact, and it is something that doesn't get used all that often. For the moment, a workaround such as suggested is the way to handle such a situation.
Allan