20 Answers, 1 is accepted
You could use the code ' RadGrid1.MasterTableView.Items.Count ' in order to get the number of records in RadGrid. If you enabled paging, then try the following code snippet for getting the record count.
I saw a lot of people looking for this code. You might want to put it in your How-To for RadGrid.
For my issue this solution worked fine since I have to state both the display count and total count.
I have the same issue. Items.Count returns only count for one page. How can I get total count without set AllowPaging to false?
May be you also know some way to get all items after filtering (array of objects, not only count)?
- I have some currentID
- And I have radgrid.MasterTableView with DataKeyNames="id"
- I want to select grid item with value == currentID
- So I have to define page and row for this item
Now I try to find this item this way:
I understand that it's not the best solution =)
When I load the page, I want to select some item in the grid. This item must have value, which I got from the Session, (it's variable parameter).
Thank you in advance, I got ideas for my current solution)
When I use RadGrid1.MasterTableView.Items.Count I get value of the page size but not actual filtered result count , where as if filtered results count is less than page size then I get actaul result count .
Page Size =10
Filter Result Count=12
I get RadGrid1.MasterTableView.Items.Count as 10
if Filter Result Count=8
I get RadGrid1.MasterTableView.Items.Count as 8
I have the same problem with my code as you mentioned, in your post you got any way to overcome that..
Thanks in advance
I have been using RadGrid with filter and playing around with it for two weeks.
You need to change RadGrid1MasterTableView.AllowPaging, not RadGrid1.AllowPaging becuase MasterTableView is the top table in RadGrid1. Which is what we see in the user interface. Most the time we should work on MasterTableView if we want to implement the data after filter. This will do the trick.
Hope this can help other developers if they still have this problem.
RadGrid1.MasterTableView.AllowPaging = false;
As another solution you could handle the ItemDataBound of the grid and to count the GridDataItem items.
the Telerik team
Please try the sample code snippet to get the count of filtered items.