Row Selector
Row Selector
Hello,
I have a table with first column called 'dataId' and also 'name' column, dataId is unique and its value is integer.
there is a way to find name where dataId = 5 for example?
i was trying this:
table.row({'dataId': 5}).data().pluck('name')[0];
Moreover, I will use dataId always but i prefer to not show it for user knowing that I am setting columns dynamically from options (i am getting them from backend).
there is a way to hide 'dataId' column but still use it?
thanks!
This question has an accepted answers - jump to answer
Answers
Use
row().data()
with therow-selector
as a function.Use
columns.visible
to hide the column.Kevin
for row().data(), most of the examples are using it inside click event and they are taking (this).
in my case I am trying to find the row based on column (dataId) value.
can i do that directly?
Did you look at the function example I linked to? There is no click event. The function will return the row(s) that match the criteria you specify. If its one row use
row().data()
. if there is a possiblity of more than one row userows().data()
.Kevin
my bad, i was trying both methods but they returned null.
I had to wait like 1-2 seconds for table creation before I get values.
thank you!
Likely you need to wait for the asynchronous ajax response. You can use
initComplete
if you want the values immediately after initialization. Use'this.api()
to get the Datatables API instance, for examplethis.api().row().data();
.Kevin