Modify cell in a hidden col (1.10.4)

Modify cell in a hidden col (1.10.4)

JoeDJoeD Posts: 3Questions: 1Answers: 0

How can I modify a cell in a hidden column?

cell().data() does not allow to set a data to invisible column. It throws an error

TypeError: cell[0] is undefined
_fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );

Code sample:
var objTable = $('#equipment').DataTable();
objTable.column( 5).visible( false);
objTable.cell( '#eq0 .eqDays').data( 11);

Moreover I do not see any other Api method which would allow to modify hidden column cell.

Thank you

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    Hi,

    Can you show me the HTML you are trying to modify. Specifically what is #eq0 .eqDays meant to select (keeping in mind that is a select applied to the cells and should select a cell).

    Perhaps you might want to use a row and column combination selector instead - like in this example: http://live.datatables.net/pawijose/1/edit .

    The error you are seeing suggests that no cells were selected.

    Allan

  • JoeDJoeD Posts: 3Questions: 1Answers: 0
    edited November 2014

    Thank you. #eq0 is row id and .eqDays is column class. Exactly as you defined in th sample.

    So As I see this works:

      table.column(1).visible( false);
      table.cell( '#eq0', 1).data(11);
    

    but this doesn't:

      table.column(1).visible( false);
      table.cell( '#eq0', '.eqDays').data(11);
    

    and just by looking to the API docs cell() definition:

    function cell( rowSelector, columnSelector [, modifier ] )
    

    I was expecting that columnSelector can also be '.eqDays'. I would say it is a bit not clear in the docs that columnSelector must be a column number.

    Thank you!

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Answer ✓

    '.eqDays'

    Won't work unless the header for the column has that class applied to it - in which case it will. The column-selector operates on the header cell for the column.

    Allan

  • JoeDJoeD Posts: 3Questions: 1Answers: 0

    Makes sense. Thanks a lot

This discussion has been closed.