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

FilterExpression Error

8 Answers 583 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Iosu Buenetxea
Top achievements
Rank 1
Iosu Buenetxea asked on 21 Oct 2008, 10:01 AM
Hello

I trying to put a filter expression on my item command, I set my filterExpression like http://www.telerik.com/help/aspnet-ajax/telerik.web.ui-telerik.web.ui.gridtableview-filterexpression.html.


I have this code:
Dim column As GridColumn = rgWorkflow.MasterTableView.GetColumnSafe("Denominacion")  
            column.CurrentFilterFunction = GridKnownFunction.Contains  
            column.CurrentFilterValue = TryCast(TryCast(rgWorkflow.MasterTableView.GetItems(GridItemType.FilteringItem)(0),  _  
                    GridFilteringItem)("Denominacion").Controls(0), TextBox).Text  
            If Not column.CurrentFilterValue = String.Empty Then 
                rgWorkflow.MasterTableView.FilterExpression = "([Denominacion] LIKE '%" & column.CurrentFilterValue & "%') " 
                'rgWorkflow.MasterTableView.FilterExpression = "[Denominacion like '%" & column.CurrentFilterValue & "%']"  
            End If 

I execute this code when the user do click in a imagebutton that I put in my FilteringItem, later in final of the ItemCommand I fill a datasource to the RadGrid and do databind.

When I do databind to the control, the application throws a PageRequestManagerServerErrorException: Expression expected.

Thanks.

8 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 22 Oct 2008, 08:54 AM
Hello JUAN,

Please set EnableLinqExpressions to false to avoid this.

Sincerely yours,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Iosu Buenetxea
Top achievements
Rank 1
answered on 22 Oct 2008, 09:24 AM
Hi Vlad

With this property to false I can filter manually.

One more question, How can I put filter expression in more columns?

Thanks,
0
Accepted
Sebastian
Telerik team
answered on 22 Oct 2008, 10:15 AM
Hi JUAN,

Consider concatenating the elements of the WHERE clause (which is reflected in the FilterExpression property of the master table) with 'AND' words in the same way as you will do that with DataView.Filter. Review the following article from the documentation for more details:

http://www.telerik.com/help/aspnet-ajax/grdoperatewithfilterexpression.html

Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike Nogen
Top achievements
Rank 1
answered on 22 Jan 2009, 10:03 AM
Hello!

I have read a lot of post where the solution is to turn of the linqexpression. What If I need to have it set to true and want to use "Applying default filter on initial load". I have read

http://www.telerik.com/help/aspnet-ajax/grdapplyingdefaultfilteroninitialload.html

Where you say

"manually in code should conform to the LINQ expression syntax instead of the old T-SQL syntax. Only thus they will be evaluated properly by the control."

Could you please give an example of syntax when using

 

EnableLinqExpressions="true" 

and how to use 

 

RadGrid1.MasterTableView.FilterExpression =

 

on 

 

Page_Load

 

 

 

0
Sebastian
Telerik team
answered on 22 Jan 2009, 10:50 AM
Hi Mike,

Review the code from the PageLoad handler in this online demo and let us know whether this helps.

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Mike Nogen
Top achievements
Rank 1
answered on 22 Jan 2009, 02:29 PM
Thank´s, I found another way also. It was by debugging the Selecting event of the Linqdatasource and see the current filter expression where I found my solution.

 

//Filter on last import on default Page_load on export
//My own custom functions  
ReportPeriod reportPeriod = new ReportPeriod();  
string LastReportPeriod = reportPeriod.GetLastReportPeriod();  

//Set the manual Linq filter expression to the radgrid
RadGrid1.MasterTableView.FilterExpression = string.Format("(iif(ReportPeriod == null, \"\", ReportPeriod).ToString().ToUpper().Contains(\"{0}\".ToUpper()))", LastReportPeriod);  

//Get the Colum within the radGrid
GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("ReportPeriod");  
column.CurrentFilterFunction = GridKnownFunction.Contains;  

//Set the filter value into the filter box in the column
column.CurrentFilterValue = LastReportPeriod

 

 

0
pluc
Top achievements
Rank 1
answered on 04 Mar 2010, 02:39 PM
Hi,

What does  "it" in "it.CustomerID = ALFKI"; mean?

Is it the DetailTableName?  If Yes, what name has the MasterTableView? 

Thank you.


0
Sebastian
Telerik team
answered on 04 Mar 2010, 05:12 PM
Hello kzimny,

"it" stands for the grid item(s) that matches the criteria. This not RadGrid specific and comes from the LINQ syntax used under ASP.NET 3.5.

Regards,
Sebastian
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Iosu Buenetxea
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Iosu Buenetxea
Top achievements
Rank 1
Sebastian
Telerik team
Mike Nogen
Top achievements
Rank 1
pluc
Top achievements
Rank 1
Share this question
or