Apply aoColumns on multiple columns together

Apply aoColumns on multiple columns together

faizan101010faizan101010 Posts: 6Questions: 0Answers: 0
edited July 2012 in Plug-ins
I have a table of 28 columns. It contain numeric values having comma. I am using "sType": "numeric-comma" to sort. Is there a way that I could initialize this type of sorting by default on some specific columns, let say on 5 columns at random position. I know I can use this code

"aoColumns": [
null,
null,
null,
{ "sType": "numeric-comma" },

But number of column are not static for me. There is an ajax slider to increase the quantity of columns and I want to apply sTpye: numeric-comma on both of them.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    You can use aoColumnDefs - http://datatables.net/usage/columns . Give the two columns that you want to be numeric comma a class of 'numeric-comma' (or whatever) in the TH element and use:

    [code]
    aoColumnDefs: [
    {
    sType: "numeric-comma",
    aTargets": [ 'numeric-comma' ]
    }
    ]
    [/code]

    Allan
  • faizan101010faizan101010 Posts: 6Questions: 0Answers: 0
    edited July 2012
    No its not working.

    My table contain values like 0.3 and 1,500

    And its showing 0.3 above 1,500.
This discussion has been closed.