column(0).cells() returns all cells in table, not just those in the first column
column(0).cells() returns all cells in table, not just those in the first column

Link to test case: https://live.datatables.net/vagenuta/2/edit
Description of problem: I want to update all the cells in the first column of a table. I select that column with column(0)
, then chain cells()
. In a 3 row, 6 column table as in my test case I would expect 3 cells to be returned - those in the first column. However, all table cells are returned.
Is this a bug, or have I misunderstood something?
A subsidiary question, in the light of the fact that internal row indices are not the same as the displayed row positions, is whether I should rely on column(0) always returning the first column in the table. (In my situation, columns are never reordered).
This question has accepted answers - jump to:
Answers
Not a bug.
cells()
is a top level selector, so the fact that you have calledcolumn()
beforehand is meaningless.Instead, use
cells()
with a row and column selector:Get's the cells from all rows and column index 0. Updated example.
Yes. Regardless of column visibility,
column(0)
will return the first column in the table. See the docs here.Allan
Thanks Allan. May I suggest you add a comment to the docs at https://datatables.net/reference/api/columns()? Not that they are wrong, but I was slightly led up the garden by the sentences
and
Thanks for the feedback. Its really important that I get feedback so I can improve the docs.
I think that is correct though is it not?
columns([0, 1]).data()
, orcolumns(1).visible(false)
for example?The same is true of the second statement, that is correct. What I perhaps need to be clearer on is that the selector methods (
.cells()
,.rows()
,.columns()
) are top level and don't take into account what has previously been selected. For example:would do exactly the same as:
Allan
Hi Allan, I agree! Thanks for taking the feedback.
I've added:
in this commit to the top level selectors, which will hopefully help clarify things.
Allan
Perfect!