Prevent row selection
Prevent row selection
Hi
http://live.datatables.net/jusiwawu/1/edit?html,js,output
I am trying to make only certain rows selectable (both programatically and via the user), and I found this which is outdated, http://www.datatables.net/forums/discussion/16308/is-there-any-way-to-make-certains-rows-unselectable-for-an-multi-selecting-table-tools
None of these do anything after page load.
datatables.CampaignTable.on( 'selectItems', function ( e, dt, items ) {
console.log( 'Selected1', items );
} );
datatables.CampaignTable.on( 'selectItems.dt', function ( e, dt, items ) {
console.log( 'Selected2', items );
} );
datatables.CampaignTable.on( 'selectItems.dt.DT', function ( e, dt, items ) {
console.log( 'Selected3', items );
} );
So basically i have an ajax data source.
And a rowCallback that I use to categorize my data as it comes in.
But I have added buttons to do batch changes to values in the table, and depending on the state of certain rows (for my specific case the content of a field, but i would prefer to use a class like no-select) i need certain rows to be unselectable.
So no user can select that row, and if i programmatically select the rows it also needs to fail.
//using a class this becomes easy to programatically not select those rows.
dt.rows('tr:not(.no-select):contains(' + value + ')').select();
But the user can still manually select the rows.
(just to clarify, I am successfully categorizing rows as 'no-select' using the rowCallback, I just need to figure out how to make the user not able to select them)
any ideas?
This question has accepted answers - jump to:
Answers
I managed to figure it out. took some experimenting.
The Select docs incorrectly have double nested select objects
heres the initialization code i used (minus the unneeded)
this can be closed
Hi,
Thanks for the update - great to hear you have it working now and for pointing out the error in the docs! I'll deploy an update to the site shortly.
Allan