argument columndef

argument columndef

you2525you2525 Posts: 23Questions: 5Answers: 0
edited April 2020 in Free community support

Hi,

I have a datatable with the first column fixed. I want the text of the first column align to the right and the rest of the columns to the left. and I don't know the number of columns. I would like to do something like this :

columnDefs: [
{ className: "dt-body-right", targets: [1:-1]},
{ className: "dt-body-left", targets: [0]}
],

but the argument targets: [1:-1] are wrong. I don't know how to code 'from column 1 to the last column'.

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,770

    As you mention the format you have for columnDefs.targets is not supported. The docs state what is supported. Maybe you can add a class to the th you want to use dt-body-right.

    Kevin

  • you2525you2525 Posts: 23Questions: 5Answers: 0

    Yes i did it with class and it worked thank you !

This discussion has been closed.