Filtering in RadGrid

5 posts, 0 answers
  1. Ramesh
    Ramesh avatar
    5 posts
    Member since:
    Jan 2011

    Posted 21 Jan 2011 Link to this post

    Hi,
     I am using Telerik Rad grid in My application. My requirement is like this.

    I have Products View with their status whether Active or Inactive. So in this grid i have two Columns named "Products" and "Status".
    Whenever the grid is loaded or in the first view of grid, User should able to see only all the Active Products. If user wants to see all products(both active & inactive) after loading the grid, he should able to see it by clicking on filter icon on that column.
    Please tell how to do this or plz give any sample code.

    Regards
    Ramesh
  2. Matti
    Matti avatar
    2 posts
    Member since:
    Jan 2011

    Posted 23 Jan 2011 Link to this post

    Hi,
    When you are loading your grid, you can do the following.
    If your status field is using the text to show status then use that as filter.
    in code behind:
    FilterDescriptor theFilter=new FilterDescriptor("Status",FilterOperator.IsEqualTo,"active",true);
    radGridView1.FilterDescriptors.Add(theFilter);
    or xaml:
    <telerik:RadGridView x:Name="radGridView1">
      <telerik:RadGridView.FilterDescriptors>
         <telerik:FilterDescriptor Member="Status" Operator="IsEqualTo" Value="active" IsCaseSensitive="True">
           </telerik:FilterDescriptor>
         </telerik:RadGridView.FilterDescriptors>
    </telerik:RadGridView>

    Or, if you are using a boolean state, like checkbox change it to this.
    FilterDescriptor theFilter=new FilterDescriptor("Status",FilterOperator.IsEqualTo,true,true); 
    radGridView1.FilterDescriptors.Add(theFilter);
    You can also use 1 instead of true as boolean state.
    and xaml:
    <telerik:RadGridView x:Name="radGridView1"
      <telerik:RadGridView.FilterDescriptors
         <telerik:FilterDescriptor Member="Status" Operator="IsEqualTo" Value="True" IsCaseSensitive="True"
           </telerik:FilterDescriptor
         </telerik:RadGridView.FilterDescriptors
    </telerik:RadGridView

    Hope this helps,

    -Matti
  3. Marco
    Marco avatar
    11 posts
    Member since:
    Dec 2011

    Posted 19 Mar 2013 Link to this post

    Hello I use the same code:
    <telerik:RadGridView.FilterDescriptors>
             <telerik:FilterDescriptor Member="RowStatus" Operator="IsNotEqualTo" Value="NotVisible"/>
    </telerik:RadGridView.FilterDescriptors>

    The RowStatus is bound to a Member in my Datasource, when I change It in my MVVM I send the  OnPropertyChanged("RowStatus").
    But unfortunately the Grid make nothing. Why the grid is not filtering, when the bound value is changing?
    Is the a possibility to restart the filter programmatically in th MVVM.

    Thank you for your help
    Marco
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Mar 2013 Link to this post

    Hello,

    In order to have the FilterDescriptors re-evaluated, you have to notify the GridView that the bound collection has been changed (CollectionChanged event to be raised). I would suggest you to edit the items as suggested in this help article. Does this solve the problem?
     

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Marco
    Marco avatar
    11 posts
    Member since:
    Dec 2011

    Posted 22 Mar 2013 Link to this post

    the tip with the EditItem and Commit hasn't worked
    Now I'm using:

    ArtikelGrid.FilterDescriptors.Clear();
    FilterDescriptor theFilter = new FilterDescriptor("RowIsVisible", FilterOperator.IsEqualTo, "True", false);
    ArtikelGrid.FilterDescriptors.Add(theFilter);

    This works, thank you
    Greetings Marco
Back to Top