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

How to delete rows marked with GridClientSelectColumn

4 Answers 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kermit
Top achievements
Rank 1
Kermit asked on 07 Aug 2012, 07:50 PM
I'm using a RadGrid with a GridClientSelectColumn and paging is enabled.  I want to perform row deletions in the ItemCommand event handler when a "Delete Checked" linkbutton in the command row is clicked.

I check two rows in the GridClientSelectColumn on the first page, then page forward to 2nd page and check 2 more rows.  When I click the "Delete Checked" linkbutton, the ItemCommand event handler spins through the radgrid.SelectedItems and deletes the two rows checked on the 2nd page, but not the two checked rows on the first page.  I do understand why it works this way.  My question is, what approach should I use to accomplish what I want to do, since this way isnt going to cut it...

4 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 10 Aug 2012, 05:17 AM
Hi Kermit,

Indeed, RadGrid does not persist the selected state of its items when it is rebound on the server. You need to do it yourself. Here is how to accomplish the persistence server-side:
http://www.telerik.com/help/aspnet-ajax/grid-persist-selected-rows-on-sorting.html

and client-side respectively:
http://www.telerik.com/help/aspnet-ajax/grid-persist-selected-rows-client-sorting-paging-grouping-filtering.html

Hope it helps.

Greetings,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kermit
Top achievements
Rank 1
answered on 10 Aug 2012, 02:05 PM
Thank you Tsvetoslav, that does help!

Kermit
0
Jon
Top achievements
Rank 1
answered on 20 Sep 2012, 08:10 PM
Hello Tsvetoslav,

I'm using the client-side solution to persist the selected items between post backs.  It works quite well to maintain the user selection when paging.

However, I have the same question that Kermit posted.  I don't see the answer in the links shown.  How do I get a collection of the selected items from all pages using the client-side persistence method?

If I use the following, I only get the GridDataItems that were selected on the current page.

foreach (GridDataItem item in RadGrid1.SelectedItems)
{
    ...
}

Do I need to put the selected item IDs in a hidden input for posting back?  Am I overlooking something in the posted examples?

Thanks,

Jon Shipman
0
Tsvetoslav
Telerik team
answered on 21 Sep 2012, 06:38 AM
Hello Mermit,

That's correct, you have to preserve the client-side array of selected data key values into a hidden field and then use it on the server to retrieve from the underlying data-source the information you need about those items: namely from the data-source, not from the grid, as the grid will have just the items for the current page.

The functionality described in the help article concerns the preservation of the selected state of the items, not the items themselves.

All the best,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Kermit
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Kermit
Top achievements
Rank 1
Jon
Top achievements
Rank 1
Share this question
or