How to Add Checkboxes to Your Table and Add Logic to Them!
The following is a solution for adding checkboxes with logic to your table. As well as a solution to know which record gets selected.
Step 1
Add an action link to your table.
Step 2
Add a CSS class of "check" to your action link.
Step 3
In the JavaScript tab of your page, add the following code.
TB.render('component_3', function(data) {
var elems = document.getElementsByClassName("check");
for (let i = 1; i < elems.length; i++) {
elems[i].innerHTML = "<input type='checkbox'>";
}
});
Remember to change the component ID within the code above to match the component ID of your table containing the action link.
In case you want to know which record gets selected, you can add this to code a custom component:
var checkboxes = document.getElementsByClassName("check");
for (let i = 0; i < checkboxes.length; i++) {
if(checkboxes[i].checked){
// Do your logic
//If you want to get ID of each record you should pass it in the checkbox innerHTML
}
}
We'd love to hear your feedback.