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

How to delete selected rows cilent-side only?

5 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
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

Sort by
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?

0
Iana Tsolova
Telerik team
answered on 20 May 2009, 02:52 PM
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.
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
Iana Tsolova
Telerik team
answered on 22 May 2009, 03:51 PM
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.
Tags
Grid
Asked by
AdrianTaylor
Top achievements
Rank 1
Answers by
AdrianTaylor
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or