Aligning columns

Aligning columns

paulsperanzapaulsperanza Posts: 6Questions: 0Answers: 0
edited April 2009 in General
Is there a way to set the alignment on a column? I don't think that I saq one in the docs.

Thanks

Replies

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    edited April 2009
    Hi paulsperanza,

    The best way to do something like this is through a class style. If you just apply a class name to each cell in that column, then you can align the information as required (text-align:center; for example).

    So if you are reading your table information from the DOM any classes there will be maintained (see the example on the home page - http://datatables.net/index - for this). Alternatively, you can ask DataTables to apply a class to a column using 'sClass': http://datatables.net/usage#sClass

    Hope this helps,
    Allan
  • paulsperanzapaulsperanza Posts: 6Questions: 0Answers: 0
    Thanks Allan,

    I used the sClass. I was going to do this anyway but I wanted to be sure i wasn't missing some property for the columns. You have done a great job with this. I am shaking it out but so far I think it is the best JQuery grid out there.

    I work with .Net and I was thinking of extending their Gridview control to wrap DataTables. The only problem is that you have so many options it might take me forever to do it :0) It may just be easier to set up the script by hand.

    Keep up the great work.
    Paul
  • ganeshananthanganeshananthan Posts: 1Questions: 0Answers: 0
    edited May 2014

    I've used nth column css trick for this.<br>
    //6th column is my currency column, which needs to be right aligned<br>

    .reporta td:nth-child(6)
    {
    text-align:right !important; }
This discussion has been closed.