count filtered rows in group

2 posts, 0 answers
  1. AJing
    AJing avatar
    19 posts
    Member since:
    Jun 2011

    Posted 29 Nov 2011 Link to this post

      Is there a way of counting the visible rows after applying a filter or multiple filter and a group or many group?
      eg: There is a group template by Age column and I apply a filter in city column. How can I count the filtered rows?
       Our code as follows:
        label1.Text= radGridView.MatserTemplate.ChildRows.Where(o=>o.City='NanJing').Count;
    If there is only filter ,the label1's text display filtered rows .But if there is a group ,the label1's text display zero.
    I want the label1's text display filtered rows .

    Look forward to you
  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 02 Dec 2011 Link to this post

    Hi Ajing,

    The ChildRows collection is hierarchical structure and in your case in order to find only the filtered rows, you must count only the data rows. You can use this simple implementation:

    private int GetDataRowCount(GridViewChildRowCollection collection)
        int count = 0;
        foreach (GridViewRowInfo row in collection)
            if (row is GridViewDataRowInfo)
                count += GetDataRowCount(row.ChildRows);
        return count;

    For additional information about the ChildRows collection, please refer to this article.

    If you have other questions, do not hesitate to contact me again.

    Julian Benkov
    the Telerik team

    Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Back to Top