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

[Solved] AllowFilteringByColumn="true" causes "Expected ')'" page error

15 Answers 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brandon
Top achievements
Rank 1
Brandon asked on 25 Jun 2014, 04:17 PM
Hello,

My RadGrid was working fine when loading a datasource before I set AllowFilterByColumn="true" on it. Now I get a pop-up with a page error "Expected ')'". I try to debug the page but it doesn't break on the error, so I'm assuming it's being raised in one of the Telerik js files. Any idea what's going on here?

Thanks.

15 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Jun 2014, 03:33 AM
Hi Brandon,

Please set EnableLinqExpressions="false" for the Grid to avoid this error.

ASPX:
<telerik:RadGrid ID="rgridSample" runat="server" EnableLinqExpressions="false" . . >

Thanks,
Princy
0
Brandon
Top achievements
Rank 1
answered on 26 Jun 2014, 01:37 PM
Princy,

I already have that in there. It's still not working.
0
Gaurab
Top achievements
Rank 1
answered on 26 Jun 2014, 02:45 PM
What are you using for the datasource for the RadGrid?  A declared datasource (SqlDataSource, etc.) or the OnNeedDataSource event?
0
Brandon
Top achievements
Rank 1
answered on 26 Jun 2014, 02:47 PM
It is a System.Data.DataTable, set in the OnNeedDataSource event.
0
Gaurab
Top achievements
Rank 1
answered on 26 Jun 2014, 03:10 PM
OK.  Good deal.  It sounds like there something wrong with the filter expression.  When a filter is applied, it should raise the OnNeedDataSource event.  Put a breakpoint in the OnNeedDataSource handler, then you'll want to get the YourGridName.MasterTableView.FilterExpression and have a look at it and see if you can tell what's wrong with it.

When it's paused on the breakpoint you can get the value from the Immediate Window, or you can put a line of code in there like:

var filterExpression = YourGridName.MasterTableView.FilterExpression;

, then put your breakpoint on the next line after it and see what the value of filterExpression is.  Hopefully you'll be able to see what the problem is by looking at the value.
0
Brandon
Top achievements
Rank 1
answered on 26 Jun 2014, 03:54 PM
The FilterExpression is just an empty string.
0
Gaurab
Top achievements
Rank 1
answered on 26 Jun 2014, 06:43 PM
I hope I'm not leading you down the wrong trail.  Just to be sure, the FilterExpression will be an empty string the first time your grid loads.  However, when you apply a filter, by clicking something in the filters from the UI, it will raise the OnNeedDataSource again and this time the FilterExpression should not be an Empty String.

Did you check it after you clicked on a filter?  If so, I'll step aside and let the Telerik folks take it from here.
0
Brandon
Top achievements
Rank 1
answered on 26 Jun 2014, 07:19 PM
Well, the error is popping up the first time the grid loads. If I try to filter anyway, I get a FilterExpression such as "([SSN] LIKE '%4%')".
0
Gaurab
Top achievements
Rank 1
answered on 26 Jun 2014, 07:30 PM
I don't suppose there's an "Initial Filter" set like shown in one of the methods on this page???  Again, I hope I'm not wasting your time here.  It still seems like it's a FilterExpression issue, but it is hard to diagnose without seeing the whole picture.
0
Brandon
Top achievements
Rank 1
answered on 26 Jun 2014, 07:49 PM
There is no initial filter. I tried to manually set it to string.Empty at multiple points throughout the page life-cycle, but that did no good either. Thanks for your help.
0
Princy
Top achievements
Rank 2
answered on 27 Jun 2014, 04:33 AM
Hi Brandon,

Can you please provide your full code snippet. With so less information its hard to identify the issue.

Thanks,
Princy
0
Brandon
Top achievements
Rank 1
answered on 27 Jun 2014, 01:47 PM
Can you narrow exactly what I need to post? I'm not going to paste over 400 lines of code here.
0
Princy
Top achievements
Rank 2
answered on 30 Jun 2014, 11:24 AM
Hi Brandon,

Please paste the code where you are writing the FilterExpression, to apply filtering for the column and the event used.

Thanks,
Princy
0
Brandon
Top achievements
Rank 1
answered on 30 Jun 2014, 01:49 PM
There is no code where I set the filter expression. It is all done behind the scenes. Also, the error isn't just happening when I try to set a filter - it happens as soon as I try to load the data source.
0
Princy
Top achievements
Rank 2
answered on 02 Jul 2014, 05:06 AM
Hi Brandon,

I'm not able to replicate the issue. Please note that you should never call the Rebind() method in a NeedDataSource event handler.You should never call DataBind() as well when using advanced data binding through NeedDataSource. Below is a sample code snippet, please try to replicate the issue with this code.

ASPX:
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>

C#:
RadGrid _RadGrid1;
protected void Page_Init(object source, System.EventArgs e)
{
    _RadGrid1 = new RadGrid();
    _RadGrid1.ID = "RadGrid1";
    _RadGrid1.MasterTableView.DataKeyNames = new string[] { "OrderID" };
    _RadGrid1.PageSize = 15;
    _RadGrid1.AllowPaging = true;
    _RadGrid1.AutoGenerateColumns = false;
    _RadGrid1.AllowSorting = true;
    _RadGrid1.AllowFilteringByColumn = true;
    _RadGrid1.GroupingSettings.CaseSensitive = false;
    _RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
 
    GridBoundColumn boundColumn;
    boundColumn = new GridBoundColumn();
    boundColumn.DataField = "OrderID";
    boundColumn.HeaderText = "OrderID";
    boundColumn.SortExpression = "OrderID";
    _RadGrid1.MasterTableView.Columns.Add(boundColumn);
 
    boundColumn = new GridBoundColumn();
    boundColumn.DataField = "ShipCountry";
    boundColumn.HeaderText = "ShipCountry";
    boundColumn.SortExpression = "ShipCountry";
    _RadGrid1.MasterTableView.Columns.Add(boundColumn); 
 
    this.PlaceHolder1.Controls.Add(_RadGrid1);   
}
 
void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    _RadGrid1.DataSource = GetDataTable("SELECT * FROM Orders");
}
 
 
public DataTable GetDataTable(string query)
{
    String ConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    SqlConnection conn = new SqlConnection(ConnString);
    SqlDataAdapter adapter = new SqlDataAdapter();
    adapter.SelectCommand = new SqlCommand(query, conn);
 
    DataTable myDataTable = new DataTable();
 
    conn.Open();
    try
    {
        adapter.Fill(myDataTable);
    }
    finally
    {
        conn.Close();
    }
    return myDataTable;
}

Thanks,
Princy
Tags
Grid
Asked by
Brandon
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Brandon
Top achievements
Rank 1
Gaurab
Top achievements
Rank 1
Share this question
or