change cell data by row and column indexes or filters

change cell data by row and column indexes or filters

nevzatanevzata Posts: 3Questions: 1Answers: 0
edited June 2018 in Free community support

Hi,

I defined column names to my table. I want to get/set a cell's contents via row/column indexes or names but somehow it's not working.

for example :
dtable.row(rowIdx).column(colIdx).cell().data("<i class='fa fa-check'></i>")
or
dtable.row("#rowId").column(colIdx).cell().data("<i class='fa fa-check'></i>")
or
dtable.row("#rowId").column("colName:name").cell().data("<i class='fa fa-check'></i>")

only changes the first column's data in that row :(

also;
to get the cell contents, I use:
dtable.row("#rowid").column(colIdx).data()[0]
but I can't get the selected column's data, only the first cell data is returned.

I also can't get the html td item of a specific cell, e.g.
dtable.row("#rowid").column(colIdx).node()
dtable.row("#rowid").column(colIdx).cell().node()
dtable.row("#rowid").column(colIdx).data().node() ?
I'm lost in the syntax

Where is my mistake?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586
    Answer ✓

    Hi @nevzata ,

    Take a look at this example here - this is showing how to use cell() to get the required cell,

    Cheers,

    Colin

  • nevzatanevzata Posts: 3Questions: 1Answers: 0

    many thanks colin,
    dtable.cell("#rowid",colidx).data("newdata");

    works but
    dtable.cell(rowidx, colidx).data("newdata");
    doesn't work, I don't know why?

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

    Hi @nevzata ,

    The rowIdx isn't the row position of that row in the table, as the table may have different sorting at any one time. The rowIdx would be the order the row was loaded originally, such as it's place in the DOM or the order in the JSON.

    If that isn't the case, please create a test case, you can even change mine above, that demonstrates the problem - I'm happy to take a look,

    Cheers,

    Colin

  • nevzatanevzata Posts: 3Questions: 1Answers: 0

    thanks again @Colin, using row id's to select rows make more sense now because of the ever-changing order as you said. I'll use id's to select rows.

This discussion has been closed.