How to delete rows marked with GridClientSelectColumn

5 posts, 0 answers
  1. Kermit
    Kermit avatar
    20 posts
    Member since:
    Jan 2012

    Posted 07 Aug 2012 Link to this post

    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...
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 10 Aug 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kermit
    Kermit avatar
    20 posts
    Member since:
    Jan 2012

    Posted 10 Aug 2012 Link to this post

    Thank you Tsvetoslav, that does help!

    Kermit
  5. Jon
    Jon avatar
    5 posts
    Member since:
    Nov 2011

    Posted 20 Sep 2012 Link to this post

    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
  6. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 21 Sep 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017