I've got a grid with one column. The row at ID 1 (index 0) cannot be deleted.
I'm using the javascript function:
function verify_delete(sender, eventArgs) { var continueDelete = confirm("Are you sure you want to delete this row?"); if (!continueDelete) eventArgs.set_cancel(true);}
to confirm deletion already. Would be nice to be able to check for the index of the selected row at the same time and if its row index 0 then set cancel to true.
So far tho I can't find the selected row. Any help??
Chuck
Thanks, works perfectly. Just couldn't get the phraseology correct.
Hi Chuck,
I am going to assume you have only single row selection on. If not, you may have to do a search through the rows or just remove that row.
var index = eventArgs.get_rows().getItem(0).get_index();
if (index === 0)
eventArgs.set_cancel(true);
eventArgs.get_rows() also has a remove method if you wanted to simply remove the row if it had an index of 0. You could use a for loop to go through the rows (I'd start at the end and work your way to the front).
regards,David Young