Footer column not showing number aligned right (DT 2.3.3)
Footer column not showing number aligned right (DT 2.3.3)

Link to test case: No
I am surprised I can't find an example showing a numeric column summarized. I was hoping to not have to work up an example.
Description of problem:
In DataTable 2.3.3 my footer numeric columns are left aligned.
I had to add dt-head-left to the numeric and date columns to allow the sort icons to be on the right (suggestion in v2.3.1 fixes)
Looks like the is causing the numeric footer columns to be left justified.
Any suggestions?
This question has an accepted answers - jump to answer
Answers
I built a simple test case:
https://live.datatables.net/mozuviyo/1/edit
Looks like the
className: 'dt-head-left'
option is applied to the footer. According to the styling docs this should only be applied to the header. This rule is being applied:One option is to use
initComplete
to remove thedt-head-left
class from the footer, like this example:https://live.datatables.net/lukuyode/1/edit
@allan can comment on whether this is exepcted behavior and if the code or documentation needs fixed.
Kevin
There is an example here.
I'll need to have a little think about the right course for the class names. Thanks for highlighting that.
Allan
While you are thinking through the issue I have a related question.
If there is no data yet for the DataTable the sum value of 0 is shown, but it is aligned to the left and not the the right.
Here is the example from @kthorngren with the workaround to remove the
dt-head-left
from the footer via initComplete. I have removed all the data.https://live.datatables.net/cifehabi/2/edit
Here is the image from one of my panels

I would expect that to be the case. It can only work out what class should be automatically applied when the data is loaded. Prior to that it will get default alignment. A class name needs to be set for the column in the initialisation or HTML if you know ahead of time what the type is and what the alignment should be.
Allan
Inspecting the
th
it looks like this rule is applied:You can create a custom CSS to overide the Datatables CSS, like this:
Updated example.
https://live.datatables.net/cifehabi/3/edit
Kevin
Going back to my first test case the
th
has the classdt-type-numeric
applied which causes the number to be right justified:It looks like with no data type detection doesn't run which means the
dt-type-...
classes aren't applied. Another option is to apply thedt-type-numeric
class usingcolumns.className
, for example:https://live.datatables.net/cifehabi/4/edit
I just realized the above selector applies to all the
th
in the footer. You could make it more specific to just the desired columns. For example:Test case:
https://live.datatables.net/cozuqule/1/edit
Note I commented out the
initComplete
code. This might be a better overall solution.Kevin