How to count selected items in RadGrid

4 posts, 0 answers
  1. Brian
    Brian avatar
    26 posts
    Member since:
    Dec 2008

    Posted 28 Sep 2009 Link to this post

    Hopefully this is a simple question.


    I've got Radgrid (Ajaxed) and with Paging enabled

    How do I create a label on the page and then have the label updated with the count of all selected items


    I've correctly got this javascript attached to the RadGrids (ClientEvents - onrowcreated, onrowdeselected, onrowselected)

     var rgGrid = $find("<%= RadGridBirthdays.ClientID %>"); 
                   var MasterTable = rgGrid.get_masterTableView(); 
                   var selectedRows = MasterTable.get_selectedItems(); 
                   document.getElementById('<%= this.SelectedCount.ClientID %>').innerHTML = selectedRows.length; 

    The problem is when i go to the next page my count resets so the actual count is never correct.


    Can someone please explain how to get the count (the correct way ) with paging enabled.


  2. Mira
    Admin
    Mira avatar
    1124 posts
    Member since:
    Sep 2012

    Posted 28 Sep 2009 Link to this post

    Hello Brian,

    To learn how to achieve the desired functionality, please take a look at the Persisting the selected rows server-side on sorting/paging/filtering/grouping or at the Persisting the selected rows client-side on sorting/paging/filtering/grouping help topics depending on the way of selection.
    I recommend that you also have an asp:HiddenField holding the count of selected indexes on all pages and update it and the label as well on paging.

    Best wishes,
    Mira
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

  3. Brian
    Brian avatar
    26 posts
    Member since:
    Dec 2008

    Posted 01 Oct 2009 Link to this post

    You wouldnt happen to have an example of such a operation


    Would prefer to do most of this client side if possible 

    What I am doing is taking the selected items and then using them on another page (but as the selected items are not saving between pages I need get the right number of items back)

    If i've got a hidden field which I take it will save the item keyvalues? then i can use the field to fill a session arraylist that i'm using on the next aspx page.




  4. Mira
    Admin
    Mira avatar
    1124 posts
    Member since:
    Sep 2012

    Posted 06 Oct 2009 Link to this post

    Hello Brian,

    I am attaching a sample project showing how to implement the desired by you functionality.

    Please take a look at it and tell me whether you find it useful.

    All the best,
    Mira
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

Back to Top