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

Understanding FilterExpression

1 Answer 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stan
Top achievements
Rank 1
Stan asked on 16 Feb 2012, 05:56 PM

RadGrid with filters is bound to a collection of objects. When filter changes, there is an async postback during which I can determine the filters by examining FilterExpression property which has the values like this:

(iif(CatalogNumber == null, \"\", CatalogNumber).ToString().ToUpper().StartsWith(\"na\".ToUpper()))

What I want to do with this is filter the collection of object on server which the grid is bound to and looks like this:

 

 

private List<LineItem> _lineItems = new List<LineItem>

 

{

 

new LineItem { Id="4300" CatalogNumber="ab" },

 

 

new LineItem { Id="4301"CatalogNumber="naf-1"}

 

 

}

 

};

I am not sure how FilterExpression can be used in this situation and why it has these "iif" and so on.  I don't want brute force method of parsing it out and thinking that there maybe a reason why it has this format. How can I plug it in to the custom collection to filter it?

-Stan

 

1 Answer, 1 is accepted

Sort by
0
Stan
Top achievements
Rank 1
answered on 17 Feb 2012, 06:48 PM
I found the answer - simply plug in FilterExpression into Where extenstion method provided by System.Linq.Dynamic (this is a source file download from Microsoft):

var filterExpression = gridOrderLineItems.MasterTableView.FilterExpression;
 if (!string.IsNullOrEmpty(filterExpression))
         allItems = allItems.AsQueryable().Where(filterExpression).ToList();

-Stan
Tags
Grid
Asked by
Stan
Top achievements
Rank 1
Answers by
Stan
Top achievements
Rank 1
Share this question
or