Find parent of selected within button action
Find parent of selected within button action
glimpsed_chaos
Posts: 140Questions: 30Answers: 4
I'm using the Select extension with Buttons on my table. I have a button with an action function which will get the selected row. That's all fine and I get the values as needed from this selected row.
I am trying to get the parent of this row, the '<tr>' , so I can check if it contains a specific class.
I've searched and seen some solutions but I have not been able to apply that in this scenario.
buttons: [
{
text: 'MyButton',
action: function (e, dt, node, config) {
var selectedData = table.row({ selected: true }).data();
}
}
]
Replies
I've tried evaluating this within the action but it comes back as false.
I would have that the table.row({ selected: true }) would be the <tr> I am looking to check.
Use
row().node()
to get thetr
. See if this works:Kevin
@kthorngren
I tried it and no luck.
Here is a demo to show - https://live.datatables.net/caqutoru/2/
If you select 'Cedric Kelly' row it should log to the console "This row is flagged". And not for that any when other row is selected.
No matter what row selected I cannot get it to properly determine the class on the row.
@kthorngren
I found out what it was... ugh! That little period should not be present when looking for the class.
Fixed example -
https://live.datatables.net/caqutoru/3/edit
Thanks for pointing me to the "node" solution.