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

Grid Filter error, Syntax error: Missing operand after '["column"]' operator.

5 Answers 352 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rory
Top achievements
Rank 1
Rory asked on 15 Jul 2010, 06:56 PM
Hi I recently upgraded to Version=2010.1.519.40 afterwards we started getting this Grid Filtering error;
"Syntax error: Missing operand after '["column"]' operator."

We get a different error when filtering an INT column:
"The expression contrain undefined function call Convert.ToDecimal()."

Then to top it off when leaving the page we get a "null object" error but only when the grid is filter, sorted, or grouped by using the HeaderContextFilterMenu. If you turn this feature off and sort, filter, or group by the default method it doesn't throw this error.

I am not sure what changed but this is a deal breaker for us. We wil most likely have to roll back so any help would be greatly appreciated.
Thanks

5 Answers, 1 is accepted

Sort by
0
Rory
Top achievements
Rank 1
answered on 15 Jul 2010, 10:02 PM
So I found out error 1 is related to a change in the RadGrid.MasterTableView.FilterExpression. Previously this string was compatible with DataTable.DefaultView.RowFilter this no longer seems to be the case.
New FilterExpression looks like this "(it[\"InsuredTypeName\"].ToString().Contains(\"Ben\"))"
 
It appears to be something custom for RadGrids. Anyone have an idea how to get the standard row filter out of the RadGrid.MasterTableView?


Also the error 2 with refreshing or leaving the page is still an issue with the HeaderContextFilterMenu.
0
Rory
Top achievements
Rank 1
answered on 15 Jul 2010, 11:10 PM
Ok Looks I'm going to fix this myself before anyone else even chimes in.

My error 1 can be fixed by Disable Linq Expression in the RadGrid with the attribute "EnableLinqExpressions." This isn't good enough though because now I'm curious as to how we can take a Linq Filter Expression and filter a DataView.
0
Rory
Top achievements
Rank 1
answered on 16 Jul 2010, 01:23 AM
So my latest idea is how can we create and filter a new DataView object with this Linq GridFilterExpression. I can't find anywhere that this is Linq sysntax and it was said that it can be done here. http://www.telerik.com/help/aspnet-ajax/get-filterexpressions.html
I did downloaded the Dynamic Linq Library but couldn't find anywhere that they are buliding Linq quieries from a string that looks like the radGrid.MasterTableView.FilterExpression. 

I wish it where easy like so.

DataTable

 

 

newTable = tableOne.AsEnumerable()

 

.Where(radGrid.MasterTableView.FilterExpression)

.CopyToDataTable();


Has anyone built a new DataView from this filterExpression? 

0
Accepted
Nikolay Rusev
Telerik team
answered on 21 Jul 2010, 09:05 AM
Hello Rory,

RadGrid of RadControls for ASP.NET AJAX uses different syntax for building filter expressions for 3.*/4.0 framework.

If you need to filter DataTable with FilterExpressions build from RadGrid you should include DynamicLinq and use following line to achieve it:
var newTable = <tableInstance>.AsEnumerable().AsQueryable().Where(RadGridFilterExpressions).CopyToDataTable();


Regards,
Nikolay
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
0
Rory
Top achievements
Rank 1
answered on 22 Jul 2010, 09:59 PM

Thanks it works great I had to add some defensive code because in some instances the filterexpression is blank and or the datasource is empty.

if (filterExpression.Length > 0)
{
    var tempTable = ds.Tables[0].AsEnumerable().AsQueryable().Where(filterExpression);
    if (tempTable.Count() > 0)
    {
        dsCopy.Load(tempTable.CopyToDataTable().CreateDataReader(),            
                              LoadOption.OverwriteChanges, strTables);
    }
}
Tags
Grid
Asked by
Rory
Top achievements
Rank 1
Answers by
Rory
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or