
AdrianTaylor
Top achievements
Rank 1
AdrianTaylor
asked on 20 May 2009, 01:38 PM
How can I delete all selected rows on the client in RadGrid without doing a postback?
I already use a GridClientDeleteColumn for individual rows (with a single postback later).
I want to select several rows and achieve the same effect. I found MasterTableView.deleteSelectedItems() but it does a postback. Should I cancel it? Can I use MasterTableView._clientDelete(event) directly?
Thank you.
5 Answers, 1 is accepted
0

AdrianTaylor
Top achievements
Rank 1
answered on 20 May 2009, 02:28 PM
I've been looking at the demo, Grid / Client-side Insert/Update/Delete and I adapted the following:
var grid = $find("<%=FormView1.FindControl("MemberRadGrid").ClientID %>").get_masterTableView();
var table = grid.get_element();
var dataItems = grid.get_selectedItems();
for ( i=0; i<dataItems.length; i++ )
{
dataItem = dataItems[i];
rowIndex = dataItem.get_element().rowIndex;
table.deleteRow(rowIndex);
dataItem.dispose();
Array.remove(grid._dataItems, dataItem);
}
It works visually - the row is removed from the grid. However on postback the selectedItems are not removed from the database using the delete method of my datasource. I understand that there must be something else to do to mark the dataItem as deleted on the client. The demo works by using a webservice and deleting the record immediately. I want to wait for a postback.
What does MasterTableView._clientDelete() do that I have not done?
var grid = $find("<%=FormView1.FindControl("MemberRadGrid").ClientID %>").get_masterTableView();
var table = grid.get_element();
var dataItems = grid.get_selectedItems();
for ( i=0; i<dataItems.length; i++ )
{
dataItem = dataItems[i];
rowIndex = dataItem.get_element().rowIndex;
table.deleteRow(rowIndex);
dataItem.dispose();
Array.remove(grid._dataItems, dataItem);
}
It works visually - the row is removed from the grid. However on postback the selectedItems are not removed from the database using the delete method of my datasource. I understand that there must be something else to do to mark the dataItem as deleted on the client. The demo works by using a webservice and deleting the record immediately. I want to wait for a postback.
What does MasterTableView._clientDelete() do that I have not done?
0
Hello Adrian,
Have you tried rebinding your grid after the record deletion? Also please confirm that the grid is bound client-side as it is in the mentioned demo.
Let me know how it goes.
Greetings,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Have you tried rebinding your grid after the record deletion? Also please confirm that the grid is bound client-side as it is in the mentioned demo.
Let me know how it goes.
Greetings,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

AdrianTaylor
Top achievements
Rank 1
answered on 20 May 2009, 02:59 PM
Unfortunately I am binding server-side.
0

AdrianTaylor
Top achievements
Rank 1
answered on 20 May 2009, 03:33 PM
Is there someway I can see what MasterTableView._clientDelete() does as called by the GridClientDeleteColumn in my grid? This is working well with my server-side bound grid. I just want to acheive the same thing on multiple dataItems.
Thank you Iana.
0
Hi AdrianTaylor,
In this case I suggest that you try following this online demo in order to achieve desired functionality.
Regarding the mentioned client method: This is an internal method and you can see it definition if you have or download the controls source code.
All the best,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
In this case I suggest that you try following this online demo in order to achieve desired functionality.
Regarding the mentioned client method: This is an internal method and you can see it definition if you have or download the controls source code.
All the best,
Iana
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.