table.row.add() with defined columns
table.row.add() with defined columns
why when I define a table with columns is the row.add() adding each data element to each cell?
in the example below, you will see table1 is displaying incorrectly.
http://live.datatables.net/sapasuxu/1/edit
I'm guessing the syntax needs to be different for the row.add()???
RequestDetailTable.row.add([0, value.RESPONSIBILITY_ID, value.RESPONSIBILITY_NAME]).draw();
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
For Table1 you are defining
columns.dataasnullfor all the columns. The docs state this when usingnull:This is why you are seeing the full row of data in the 2nd and 3rd columns. You could use
columns.renderto extract the particular data you want.A better option, since your row data structure is objects, is to use
columns.datato define the columns. Its much easier and you can add all the rows at once. See Table3 of the updated example:http://live.datatables.net/sapasuxu/2/edit
Kevin
ah, I always thought if a value was in columns.data it was going to look for a data source, like from an ajax call. good to know.
thanks.