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

[Solved] Deleting Row from RadGrid

3 Answers 699 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ivaylo
Top achievements
Rank 1
Ivaylo asked on 20 Feb 2010, 07:57 AM
Hello,
I'm building an application that uses RadGrid and I want to know is there a way to delete a row(and the DataItem) from the RadGrid using only JavaScript.

I.Hinov

3 Answers, 1 is accepted

Sort by
0
Ivaylo
Top achievements
Rank 1
answered on 20 Feb 2010, 08:04 AM
I mean that user select row and than clicks Delete Button from RadToolBar
0
Princy
Top achievements
Rank 2
answered on 22 Feb 2010, 04:58 AM
Hi,

You can make use of the GridClientDeleteColumn  provided by the RadGrid for a  client-side delete which allows you to erase records without making a round trip to the server.
Please take a look at the following for a working demo on how to achieve this:


Thanks,
Princy
0
Ivaylo
Top achievements
Rank 1
answered on 22 Feb 2010, 09:46 AM
Hello,
I'm aware of this samples. I'm not using Web Service or any kind of DataSource(SqlDataSouce etc.). I bind the grid to my own collection of objects at the OnLoad() of the page. I'm setting the ClientDataKeyNames,DataKeyNames properties of the grid to the ID property of my objects. So when, as shown in second sample, I try the following code:
 var table = $find("<%= RadGrid1.ClientID %>").get_masterTableView().get_element(); 
                var row = table.rows[currentRowIndex]; 
                table.deleteRow(currentRowIndex); 
                 
                var dataItem = $find(row.id); 
                if (dataItem) 
                { 
                    dataItem.dispose(); 
                    Array.remove($find("<%= RadGrid1.ClientID %>").get_masterTableView()._dataItems, dataItem); 
                } 
 but the dataItem is null and it's not removed, and all rows from the grid disappear.
Tags
Grid
Asked by
Ivaylo
Top achievements
Rank 1
Answers by
Ivaylo
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or