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

Programmatically building a Composite Filter

2 Answers 128 Views
DataFilter
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Helen
Top achievements
Rank 2
Helen asked on 30 Mar 2011, 12:17 AM
I'm having a problem trying to programmatically build a filter for the following situation, on a RadDomainDataSource.

The filter .ANDs a filter based on FK guid (department_uid) with another Composite Filter which ORs 2 filters on text comparing the first letters of FirstName and LastName fields.

Another wrinkle is that the Guid comes from a comboBox, and I have added an extra item "All" to its ItemsSource in which case the user does not want to filter by the FK relationship.

It works fine when I just use the Composite filter for FirstName & LastName.

When I create another CompositeFilter which includes the above CompositeFilter and try to add the filter for the Guid, I have to put Guid.Empty for the initial value, or it errors out with a type error. That results in all the records being filtered out. I tried using a string type for the filter, and converting the Guid to a string in the ComboBox's selectionchanged event, but that errors out too.

Any suggestions?

Could I suggest that you change the RadDataFilter in the future to allow nullable types, and to allow the user to specify a default value for don't filter?

Thanks

Helen

2 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 31 Mar 2011, 08:59 AM
Hi Helen,

There is a special singleton value for "don't filter" called FilterDescriptor.UnsetValue. When you create a FilterDescriptor which Value is equal to FilterDescriptor.UnsetValue it will be totally ignored by the data engine. It will be like you have never added it in the first place.

I hope this helps.

Kind regards,
Ross
the Telerik team
0
Helen
Top achievements
Rank 2
answered on 31 Mar 2011, 08:04 PM
YES! Exactly what I needed! Nice & clean!

RadDomainDataSource rocks!!!
Tags
DataFilter
Asked by
Helen
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Helen
Top achievements
Rank 2
Share this question
or