count filtered rows

5 posts, 0 answers
  1. Jens
    Jens avatar
    1 posts
    Member since:
    Sep 2007

    Posted 18 Nov 2011 Link to this post

    Hi,

    I have a problem counting the filtered rows, e.g. I have 50 rows in the grid's DataSource table but after applying a filter, only 10 rows are shown in the grid, so what I want to count is just these 10 row (version 2011.2.11.712).

    The problem has come up already in this forum and I tried the following:

    1.grid.Items.ItemCount: results in error as the grid does not have the property Items.
    2.grid.MasterTemplate.ChildRows.Count: always returns just 1
    3. looping through grid.Rows and checking the IsVisible property or each row: is true for all 50 rows
    4. comparing the underlying table rows with grid.Rows[i].DataBoundItem as described in another thread here: does not do the trick either.

    What am I missing here? Hope you can help me with this, thanks a lot in advance

     
    
    
    
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 21 Nov 2011 Link to this post

    Hi Jens,

    Thank you for contacting us.

    You can get the currently displayed rows in the RadGridView by accessing the ChildRows property. This would give you the rows left after the filtering. Here is a code snippet which demonstrates this:

    this.radGridView1.ChildRows.Count

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

    I hope this will help. If you need further assistance do not hesitate to write back. Greetings,
    Ivan Petrov
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

  3. UI for WinForms is Visual Studio 2017 Ready
  4. Renate
    Renate avatar
    4 posts
    Member since:
    Nov 2011

    Posted 21 Nov 2011 Link to this post

    Hi Ivan,

    thank you very much!
  5. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 21 Nov 2011 Link to this post

    Jens,

    be aware that if you allow grouping on the grid, you have to count ChildRows.Count recoursively for all group headers.
    see my post about counting visible rows in this forum. 

    Regards
    Erwin
  6. Jens
    Jens avatar
    1 posts
    Member since:
    Sep 2007

    Posted 24 Nov 2011 Link to this post

    Hi erwin,

    sorry to come back so late - found your recursive method and it works just great, thank you!
Back to Top
UI for WinForms is Visual Studio 2017 Ready