Hi!
Is there a way to cancel the row selection from the callback rowSelected?
Or, maybe, prevent the execution of rowSelected if I call selection programatically?
Thanks!
Best Regards.
Hey @jkworkbx
You could call the deselect function on the row component passed into the callback:
$("#example-table").tabulator({
rowSelected:function(row){
//row - row component for the selected row
if(/* CONDITION */){
row.deselect();
}
},
});
I hope that helps,
Cheers
Oli :)
Thank U Oli.
rowDeselected callback has code that I don麓t want to be executed.
In that case you may want to use the selectableCheck callback that you can use to prevent users from selecting certain rows in the first place.
It should return true if the row can be selected and false if it cant.
$("#example-table").tabulator({
selectableCheck:function(row){
//row - row component
return row.getData().age > 18; //alow selection of rows where the age is greater than 18
},
});
I hope that helps.
Cheers
Oli :)
selectableCheck is also called when I deselect a row?
It is called whenever a user tries to toggle the selected state of a row by clicking on it so yes if the row is somehow already selected (say by a programmatic selection) then this could be used to block the deselection.
if you only wanted it to work one way, you could query the selected state of the row before making a decision on whether to allow selection/deselection or not.
Cheers
Oli :)
Thank you so much Oli!
That resolved my issue.