This is a migrated thread and some comments may be shown as answers.

OnRowSelected Not Accurate with OnRowDeleted

3 Answers 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy Yoder
Top achievements
Rank 1
Jeremy Yoder asked on 24 Jun 2010, 09:56 PM

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?

3 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetoslav
Telerik team
answered on 25 Jun 2010, 09:59 AM
Hello Jeremy,

I am afraid this behavior is by design. Attached is an easy to implement work-around.

All the best,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jeremy Yoder
Top achievements
Rank 1
answered on 25 Jun 2010, 04:17 PM

I had considered creating that type of workaround, but was concerned because if in certain scenerios, deleting a row doesn't kick off the row selection process, then the next time you try to select a row, the row selection process will be skipped. Is that a concern?
0
Tsvetoslav
Telerik team
answered on 29 Jun 2010, 02:38 PM
Hello Jeremy,

Unless you cancel the bubbling of the click event - the row should get selected. Even if we suppose that there are such scenarios, they can arise only if you implement them and in that case depending on your particular implementation you can modify the work-around accordingly. I believe, there is no reason to worry about any potential problems with the solution under discussion.

Regards,
Tsvetoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Jeremy Yoder
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Jeremy Yoder
Top achievements
Rank 1
Share this question
or