This is driving me crazy, and I have no idea why it's happening. I've got a grid with the following settings...
<telerik:GridClientDeleteColumn ConfirmText="Are you sure you want to delete the selected item?" |
ButtonType="LinkButton" Text="Delete"> |
</telerik:GridClientDeleteColumn> |
<ClientEvents OnRowSelected="RowSelected" OnRowDeleted="RowDeleted" /> |
Here's my javascript...
function RowSelected(grd, eventArgs) { |
var masterTable = grd.get_masterTableView(); |
var rows = masterTable.get_dataItems(); |
var iRow = eventArgs.get_itemIndexHierarchical(); |
var row = rows[iRow]; |
if (row == null) { |
alert('Row is Null: How is this possible?'); |
return; |
} |
var cell = row._element.cells[3]; // Get the 3rd column cell. |
if (cell == null) { |
alert('How is this possible?'); |
return; |
} |
var val = cell.innerHTML; |
alert(val); |
} |
function RowDeleted(grd, eventArgs) { |
alert('Row Deleted Done!'); |
} |
When I select a row normally, an alert shows the value in the 3rd cell. No problem there. But when I click the delete link in a row, it pops up the "Row Deleted Done!" message as expected, and then OnRowSelected gets executed, but with strange results, at times resulting in my "How is this possible?" alerts.
After all, OnRowSelected should only get kicked off if a row is selected (which apparently the code thinks is the case, even though I don't always see a row getting highlighted and I'm not telling it to select a row after the delete). But a row is somehow getting selected after the delete, so a resultant row and cell must exist since that's what caused the event to get kicked off.
So what's going on?