Is it possible to omit certain columns from aTargets or set a range of columns

Is it possible to omit certain columns from aTargets or set a range of columns

pssguypssguy Posts: 1Questions: 0Answers: 0
edited August 2013 in DataTables 1.9
Hi,
New to DataTables and using it in rCharts which has different syntax so bear with me

I have a table will which will have a varying number of columns. I want to apply a function to all but the first column.
So if the number of columns is len then "aTargets": [1,2,3...len] is what I want to pass. It does not appear that something like 1:len works
and -0 is equivalent of 0

Or failing that, can I refer to column 0 somehow in my function and exclude it with a !=

cheers

Replies

  • majortommajortom Posts: 29Questions: 0Answers: 0
    I'd also like a way to do this, but exclude the last column instead of the first
  • majortommajortom Posts: 29Questions: 0Answers: 0
    edited August 2013
    I just realized you can do this with PHP. Here is the code for excluding the first column

    [code]
    ..., "aTargets": [
    <?php
    // $len is the total number of columns that you have
    for ($i = 1; $i < $len; $i++) {
    if ($i == $len - 1) {
    echo $i;
    } else {
    echo $i . ', ';
    }
    }
    ?>
    ], ...
    [/code]

    Here is the code for excluding the last column

    [code]
    ..., "aTargets": [
    <?php
    // $len is the total number of columns that you have
    for ($i = 0; $i < $len - 1; $i++) {
    if ($i == $len - 2) {
    echo $i;
    } else {
    echo $i . ', ';
    }
    }
    ?>
    ], ...
    [/code]

    I haven't tested this out, so it may not work. But it should be close if it isn't right
  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    You could add a class name to all but the first column and then use the class name as the target. That's probably the easiest method.

    Allan
This discussion has been closed.