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

Filter results by row background

6 Answers 29 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Saykor
Top achievements
Rank 2
Saykor asked on 25 Mar 2014, 12:05 PM
Hi,
I have a WPF RadGridView and change the row background depend of 2 columns value:

<telerik:RadGridView.RowStyle>
                        <Style TargetType="telerik:GridViewRow">
                            <Setter Property="Background">
                                <Setter.Value>
                                    <MultiBinding Converter="{StaticResource HashToBackgroundConverter}">
                                        <Binding Path="OldSha3Hash"/>
                                        <Binding Path="NewSha3Hash"/>
                                    </MultiBinding>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </telerik:RadGridView.RowStyle>

If both columns have equals value then Background is green, if not then is red.

How I can make a filter to show only green or red rows?

Best regards,
Saykor

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Mar 2014, 04:42 PM
Hello,

The filtering is a data operation and you can filter adding FilterDescriptors to filter on a specific data Member or a ColumnFilterDescriptor to filter a column based on the bound data member property.
Please check our online documentation where the filtering is explained in details.

Regards,
Didie
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Saykor
Top achievements
Rank 2
answered on 25 Mar 2014, 05:30 PM
Hey Didie,
Seriously, on a specific problem the answer is "read the documentation"?

I need to do something like:

Show results where
     column1.FieldFilter.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsEqualTo;
     column1.FieldFilter.Filter1.Value = column2.Value;

And with second filter
     column1.FieldFilter.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsNotEqualTo;
     column1.FieldFilter.Filter1.Value = column2.Value;

It is possible?
0
Dimitrina
Telerik team
answered on 26 Mar 2014, 04:32 PM
Hello,

May I ask you what is the column2.Value and column1.Value
How are your columns bound (what their DataMemberBinding is)? That way I can be more specific in my answer.

Regards,
Didie
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Saykor
Top achievements
Rank 2
answered on 27 Mar 2014, 06:48 PM
Dear Didie,
Here I make for you a simple demo app to see how i bind the data, what is the values of the columns and what I need: https://www.dropbox.com/s/yc8f3aktzuocalf/FilterGridByCompareColumns.7z

I use mvvm light
ExecuteShowSameCommand need to show only green rows
ExecuteShowDiffrentCommand need to show only red rows

Thank you
0
Accepted
Dimitrina
Telerik team
answered on 31 Mar 2014, 03:20 PM
Hello,

In your case, you would like to have filtering over the way you have applied a converter to style the GridViewRows.

The built-in filtering filtering options are available to filter based on the property bound to a particular column and not based on comparing the value of the bound property to another property of the same data item. Basically you cannot achieve your goal with a simple filtering criteria.

I have added a new property to your data, AreBothEqual, and I have assigned it as a FilterMemberPath for the column bound to OldSha3Hash property.
<telerik:GridViewDataColumn DataMemberBinding="{Binding OldSha3Hash}" Header="Old Sha3Hash" FilterMemberPath="AreBothEqual"/>

Then I define the IColumnFilterDescriptors similar to:
private void ExecuteShowDiffrentCommand(RadGridView grid)
{
    GridViewColumn oldSha3Hash = grid.Columns["OldSha3Hash"];
    IColumnFilterDescriptor statusDescriptor = oldSha3Hash.ColumnFilterDescriptor;
    statusDescriptor.SuspendNotifications();
    statusDescriptor.FieldFilter.Filter1.Operator = FilterOperator.IsEqualTo;
    statusDescriptor.FieldFilter.Filter1.Value = true;
    statusDescriptor.ResumeNotifications();
}
 
private void ExecuteShowSameCommand(RadGridView grid)
{
    GridViewColumn oldSha3Hash = grid.Columns["OldSha3Hash"];
    IColumnFilterDescriptor statusDescriptor = oldSha3Hash.ColumnFilterDescriptor;
    statusDescriptor.SuspendNotifications();
    statusDescriptor.FieldFilter.Filter1.Operator = FilterOperator.IsEqualTo;
    statusDescriptor.FieldFilter.Filter1.Value = false;
    statusDescriptor.ResumeNotifications();
}

Please find the updated demo solution attached as a reference.

Regards,
Didie
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Saykor
Top achievements
Rank 2
answered on 31 Mar 2014, 06:18 PM
Yes seems this is the solution. I realized that I can make a new property to the collection to keep the record Status 10 min after post the question but keep it to see if have more better solution from this.  Based on the Status property I change the background and make a filters because it is not just true and false.

Thank you and best regards,
Saykor
Tags
GridView
Asked by
Saykor
Top achievements
Rank 2
Answers by
Dimitrina
Telerik team
Saykor
Top achievements
Rank 2
Share this question
or