Find grid rows that are not filtered

6 posts, 0 answers
  1. MikeB
    MikeB avatar
    42 posts
    Member since:
    May 2008

    Posted 11 Feb 2009 Link to this post

    Hi,
    I have a need to create a list of items from a grid using only the rows that are displayed (not filtered).  I tried to use the RowInfo.IsVisible property but it seems that all rows "IsVisible" is set to true even if the row is not visible due to it being filtered out.

    The scenario is; The user creates a filter on a gird and then clicks a button (or whatever to trigger an event) and then the program needs to be able to get values from just the un-filtered rows.

    Does anyone know how this can be done?

    Thanks,
    Mike B.

    Update:
    After more testing, the IsVisible does seem to be set to false for rows that are filtered out.
    Sorry for "jumping the gun".

    Mike B
  2. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 13 Feb 2009 Link to this post

    Hi MikeB,

    I am glad that you have found a solution for your case but I think there is a better approach to do this so I decided to drop a line.

    Each template in RadGridView has a Rows collection which contains the rows as they appear on the grid. Therefore, after you have filtered according to your preferences the rows that are displayed can be found in the Rows property of the corresponding template. I hope this is useful.

    Do not hesitate to write me back if you have more questions.

    Regards,
    Deyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Randw
    Randw avatar
    6 posts
    Member since:
    Jul 2007

    Posted 26 Mar 2009 Link to this post

    Um, I'm not finding rows that are filtered out.  All the collections in the grid that I inspect only show the unfiltered rows (Q2'08).  I'm trying to determine a record is displayed or not.  I could do it by index compared to the DataSource or search a column in the rows for a unique data value.  Anybody have code for that? 
    Thanks,
    - Rand
  5. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 30 Mar 2009 Link to this post

    Hello Rand,

    You can consider the following code:

     bool isContained = false
     
    for (int i = 0; i < this.nwindDataSet.Customers.Rows.Count; i++) 
        DataRow currentRow = this.nwindDataSet.Customers.Rows[i]; 
     
        for (int k = 0; k < this.radGridView1.Rows.Count; k++) 
        { 
            DataRowView visibleRow = this.radGridView1.Rows[k].DataBoundItem as DataRowView; 
     
            if (currentRow[0].ToString() == visibleRow[0].ToString()) 
            { 
                isContained = true
            } 
     
         } 
     
         if (!isContained) 
         { 
              Console.WriteLine(currentRow[0].ToString()); 
         } 
         isContained = false

    Basically, what I am doing is iterating over all rows that are contained in my data source I used to bind RadGridView. For each row from the data source I check whether a row with the same ID is contained in the Rows collection of the RadGridView (the visible rows). If not, I print the ID in the Console.

    I hope this will help.

    Sincerely yours,
    Deyan
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Randw
    Randw avatar
    6 posts
    Member since:
    Jul 2007

    Posted 30 Mar 2009 Link to this post

    Thanks Deyan,

    I'll use that code. Hey, such iteration of every row in a DataSet for every row in the grid is hugely inefficient and, well, not pretty.  It would seem such a basic function that Telerik should consider a built-in method to determine whether databound rows are shown or filtered. IN my case I just want to get the next unfiltered row. An array of bools or something would greatly improve this functionality.

    Thanks,

    - Rand
  7. Deyan
    Admin
    Deyan avatar
    2039 posts

    Posted 31 Mar 2009 Link to this post

    Hi Rand,

    Thanks for your question.

    Currently we do not support this functionality out of the box since it has not been requested and we think that the custom approach could be effective in most of the cases.

    Do not hesitate to write back in case of further questions.

    Greetings,
    Deyan
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Back to Top
UI for WinForms is Visual Studio 2017 Ready