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

[Solved] Multiple filters on grid - syntax?

1 Answer 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Raymond
Top achievements
Rank 1
Raymond asked on 05 Oct 2011, 10:51 PM
Hi,
I can add an initial filter like this:

.Filterable(filtering => filtering.Filters(filters =>

{

filters.Add(obj => obj.OwnerFirstNameLastName).StartsWith((

 

string)this.ViewData["OwnerName"]);

 

}))



However, for the life of me, I can't figure out how to add multiple filters. Can someone show me the proper syntax?

Thank you.
Ray

1 Answer, 1 is accepted

Sort by
0
Jake
Top achievements
Rank 1
answered on 29 Oct 2011, 06:08 PM
Took me a while to find it to, but here you go...

.Filterable(filtering => 
        {
            filtering.Filters(f => f.Add(o => o.CUSIP).StartsWith(Model.CUSIP));
            filtering.Filters(f => f.Add(o => o.Quantity).IsGreaterThanOrEqualTo(Model.QuantityLow));
            filtering.Filters(f => f.Add(o => o.Quantity).IsLessThanOrEqualTo(Model.QuantityHigh));
......and so on......          
        }                
    )

If you have nullable data types or provide empty values you may receive "null is null or not an object" JS errors. You'll need to adjust the values accordingly or change the type of comparison you are using.  For example, if you attempt to provide an empty string value when using Contains() you will receive the JS error. In this particular case you will need to change your comparison to StartsWith() or change your value.
Tags
Grid
Asked by
Raymond
Top achievements
Rank 1
Answers by
Jake
Top achievements
Rank 1
Share this question
or