In Versions prior to Q3 2010, when I filtered the grid,
counted only the visible rows, now it returns the total rows.
How can I get the number of currently visible Rows in the FilterChanged event handler?
16 Answers, 1 is accepted
I'm still getting my Q3 install uptogether, but this may help (from the release notes)
BREAKING CHANGE: The Rows collection of GridViewTemplate now contains all bound/unbound rows. The filtered, grouped, and sorted lists of rows can be accessed from the ChildRows collection of GridViewTemplate or from every GridViewRowInfo in a hierarchical view of rows.
hope that helps
My fault, was too lazy to read the Breaking Changes Section...
Wanted to play around with the new Excel filtering options but find the UI rather confusing, with 2 filter buttons with inconsistent dialogs behind - what do you think?
Glad I could help. I'm still trying to sort out a couple of issues since upgrading at the moment, but I'll have a look at it and try and let you know my thoughts. I saw it in the release details, but haven't had chance to have a play yet.
In the meantime, would you mind marking as answer.
Thanks. Speak soon.
Just like Richard said, we have a breaking change in the Rows collection and it contains all rows of a GridViewTemplate without sorting, filtering, grouping. The ChildRows contains the hierarchical view of the rows after the data operations have been applied. For example, if we have grouping on two levels, the ChildRows contains GridViewGroupRows and the ChildRows collection of each group row contains group rows. In hierarchy mode you can navigate from MasterTemplate to all inner levels using ChildRows. If you want to get a flat collection of the visible data rows for a GridViewTemplate, you must use the DataView property. The DataView of a GridViewTemplate contains the sorted and filtered rows of this template.
I hope that this clarifies the new API.
the Telerik team
Sorry my ignorance, but How can I get the number of currently visible Rows in the FilterChanged event handler?
Can't see where's The Rows collection of GridViewTemplate
You can use the ChildRows property that can be accessed from RadGridView. If you have any additional questions, do not hesitate to ask.
All the best,
the Telerik team
I use the following code in my derived Grid control.
I think your code and mine are equivalent. Maybe it's a c# to VB misunderstanding.
I do not count the group row itself. Notice the continue statement which causes an immediate new iteration of the for each loop.
In my code i += 1 is not executed for group rows.
If I'm right VB.net does also have a Continue For statement since VB.Net 2005. I guess it's a matter of personal coding preference.
Coming from a c++ background, continue seems natural to me ...
just noticed the telerik parser here does not seem to recognize Continue ...
int rowCount = myGridView.ChildRows.Count(row => row.IsVisible);
works with both filters applied and if you manually hide rows by setting row.IsVisible
I found this thread in Google search and it seemed the closest to the issue I've got. Sorry if I had to create a new topic for this.
I have encountered a problem while working with radgridview for winforms. I was to implement multi-level grouping (namely: 3 levels) in the grid, then apply filters to it, and after that count the total number of visible filtered rows in all the groups/subgroups.
Graphically the grouping looks like this:
I used "ChildRows" collection, but it always gives me "1", no matter how many filters or groups I apply.
However, when I disable grouping, it seems to work just fine with filters. Therefore, the multi-level grouping seems to be the obstacle. Since there is one row in the very first subgroup of the major group, I guess the "ChildRows.Count" shows this one and doesn't bother seeing the rest of the rows in the other subgroups grid.
I need your advice.
Thank you very much in advance.
I suppose you post your code here, otherwise you probably won't get a satisfying answer. Recursively counting the child rows should work.
When you are always getting exactly 1 row, chances are you are counting the grouping row itself.
Thank you for writing.
I am not sure how you are iterating your rows, however it seems that a simple recursive method which iterates the ChildRows of each row does the job:
Below you can find a sample project which counts the rows in RadGridView recursively and shows it in a RadMessageBox.
Let me know, should you have further questions.
Excuse me for the delay with the answer.
Thank you, Erwin, for the hint.
Thank you, George, for a solution. It seems to work fine)