How to display number of rows in a grid after filtering

6 posts, 2 answers
  1. test
    test avatar
    27 posts
    Member since:
    Feb 2008

    Posted 08 Jul 2011 Link to this post

    Hi,

    I'm trying to display the number of rows displayed in a grid after filtering it. I don't find any event that fired after filtering action.

    Thanks for your help.
  2. komathi priya
    komathi priya avatar
    30 posts
    Member since:
    Apr 2010

    Posted 08 Jul 2011 Link to this post

    hi,

    use the property  AllowPaging="True" PageSize="500" , will display the pages in the grid and items in the grid
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Svett
    Admin
    Svett avatar
    728 posts

    Posted 13 Jul 2011 Link to this post

    Hello everyone,

    You can achieve the desired behavior through handling the FilterChanged event, where you can get the count of the child rows:

    private void radGridView1_FilterChanged(object sender, GridViewCollectionChangedEventArgs e)
    {
        int rowsCount = e.GridViewTemplate.ChildRows.Count;
    }

    Kind regards,
    Svett
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. Answer
    erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 15 Jul 2011 Link to this post

    Be aware that if you enable grouping, you have to recursively count the ChildRows of every group. At least I don't know any other method.

    I use the follwing code in a class that derives from GridView: (2011Q1)

    public long GetVisibleRows()
       {
           return this._getVisibleRows(this.MasterTemplate.ChildRows);
       }
     
       private long _getVisibleRows(GridViewChildRowCollection rows)
       {
           long i = 0;
           foreach (GridViewRowInfo row in rows)
           {
               if (row is GridViewGroupRowInfo)
               {
                   i += this._getVisibleRows(row.ChildRows);
                   continue;
               }
     
               i += 1;
           }
           return i;
       }
  6. Christ
    Christ avatar
    7 posts
    Member since:
    Feb 2011

    Posted 30 Sep 2011 Link to this post

    Thank you! Just what I was looking for...

    Christ
  7. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 30 Sep 2011 Link to this post

    Glad I could be of help.
    Erwin
Back to Top
UI for WinForms is Visual Studio 2017 Ready