≡

"ColumnControl – remove dt-right class from date formatted by moment.js

"ColumnControl – remove dt-right class from date formatted by moment.js

spownspown Posts: 21Questions: 8Answers: 0

Link to test case: https://live.datatables.net/notomuja/
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

How can I reset className dt-right on date col with moment.js renderer?

DataTable.type('datetime', 'className', '');
DataTable.type('date', 'className', '');

Answers

  • spownspown Posts: 21Questions: 8Answers: 0

    Solved – you need to manually set the column type. I’m not sure why it doesn’t work without it.

     type: 'datetime',
    
  • mattewwade06mattewwade06 Posts: 5Questions: 0Answers: 0

    I’ve faced a similar issue when working with date columns formatted using Moment.js. The automatic dt-right class can be a little confusing when the expected alignment is left, so it would be helpful to have a straightforward way to override the default class for specific date columns.

    A related discussion about dt-right and column alignment can also be found here:

    https://datatables.net/forums/discussion/78174/align-cells-left-after-2-0learn more

  • allanallan Posts: 66,016Questions: 1Answers: 10,994 Site admin

    How are you setting up the renderer for the date column? You might be able to simply use:

    DataTable.type('datetime', 'className', 'dt-left');
    

    It gets a bit more complicated if you are using a custom format though?

    Allan

Sign In or Register to comment.