This is a migrated thread and some comments may be shown as answers.

Filtering in RadGrid

4 Answers 515 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramesh
Top achievements
Rank 1
Ramesh asked on 21 Jan 2011, 10:36 AM
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

4 Answers, 1 is accepted

Sort by
0
Matti
Top achievements
Rank 1
answered on 23 Jan 2011, 05:21 PM
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
0
Marco
Top achievements
Rank 1
answered on 20 Mar 2013, 12:04 AM
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
0
Dimitrina
Telerik team
answered on 20 Mar 2013, 07:32 AM
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.

0
Marco
Top achievements
Rank 1
answered on 22 Mar 2013, 09:42 AM
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
Tags
GridView
Asked by
Ramesh
Top achievements
Rank 1
Answers by
Matti
Top achievements
Rank 1
Marco
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or