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

How to count selected items in RadGrid

3 Answers 460 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 1
IT asked on 28 Sep 2009, 02:23 PM
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.


3 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 28 Sep 2009, 03:24 PM
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.
0
IT
Top achievements
Rank 1
answered on 01 Oct 2009, 09:59 AM
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.




0
Mira
Telerik team
answered on 06 Oct 2009, 10:38 AM
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.
Tags
Grid
Asked by
IT
Top achievements
Rank 1
Answers by
Mira
Telerik team
IT
Top achievements
Rank 1
Share this question
or