How to add record ID to the link in my edit buttons
How to add record ID to the link in my edit buttons

Hi all,
I have a list of users and in the last column I have an edit button, defined using columnDefs.
https://jsfiddle.net/kharmer/Lf5vxm8d/
How do I got about assigning the record ID to each edit button on each row? The documentation has confused me a little!
Best regards,
Kris...
This discussion has been closed.
Answers
You would use
columns.render
for that. It'll give you more control thatdefaultContent
that you are currently using,Colin
Here is an example using
columns.render
. It uses themeta
parameter to get the row index for the button ID.http://live.datatables.net/qemodapi/1/edit
Kevin
Thanks guys - thanks for the example.
I have it working using an onclick method; however I wondered if there was a more elegant way to build the URL with the clientID during render of the column button?
Kris...
...would taking the value from a hidden column be the best way to go instead of a data-userID attribute on the TR element?
Either way would work, I wouldn't say one is better than the other,
Colin
Oddly, every way I have seen to hide a column doesn't seem to work for me! Unless I use a Bootstrap class="d-none" on the TH and TD...
Could you link to a test case demonstrating that, please?
Colin
Hi Colin,
Thanks - I managed to find a way round this by adding a Bootstrap presentation class of 'd-none' to the relevant columns TH and TD tag and then remove it from the colVis toggle menu using the 'noVis' class. So more through CSS classes rather than programatically.
My code is more or less the same as the example in my initial post, accept I am now using columnDefs render instead of columnDefs defaultContent to add my row buttons.
Still, the following never seemed to take affect.
Thanks,
kris...
Its hard to say with just that small code snippet. Can you update your example to show the issue? Maybe its being overwritten by another
column
orcolumnDefs
option??Kevin