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

Got a "Expected token" Exception when filtering Data in Gird

9 Answers 410 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.
Will Yeung
Top achievements
Rank 1
Will Yeung asked on 12 Jan 2010, 07:18 AM
Thanks for the great extension!
It's the best grid I can find on the internet

I am using the latest 2009.12.23 version.
I expericance this error when I click filter:

Telerik.Web.Mvc.Infrastructure.Implementation.FilterParserException was unhandled by user code
  Message=Expected token
  Source=Telerik.Web.Mvc
  StackTrace:
       at Telerik.Web.Mvc.Infrastructure.Implementation.FilterLexer.Tokenize() in D:\Projects\AMDB2010\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\Parsing\FilterLexer.cs:line 64
       at Telerik.Web.Mvc.Infrastructure.Implementation.FilterParser..ctor(String input) in D:\Projects\AMDB2010\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\Parsing\FilterParser.cs:line 20
       at Telerik.Web.Mvc.Infrastructure.FilterDescriptorFactory.Create(String input) in D:\Projects\AMDB2010\Telerik.Web.Mvc\Infrastructure\FilterDescriptorFactory.cs:line 17
       at Telerik.Web.Mvc.UI.GridDataProcessor.get_FilterDescriptors() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\GridDataProcessor.cs:line 60
       at Telerik.Web.Mvc.UI.GridDataProcessor.EnsureDataSourceIsProcessed() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\GridDataProcessor.cs:line 117
       at Telerik.Web.Mvc.UI.GridDataProcessor.get_PageCount() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\GridDataProcessor.cs:line 70
       at Telerik.Web.Mvc.UI.GridRenderer`1.Pager() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\GridRenderer.cs:line 248
       at Telerik.Web.Mvc.UI.Grid`1.WriteFooter(IGridRenderer`1 renderer) in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\Grid.cs:line 555
       at Telerik.Web.Mvc.UI.Grid`1.WriteTable(IGridRenderer`1 renderer) in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\Grid.cs:line 427
       at Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\Grid.cs:line 386
       at Telerik.Web.Mvc.UI.ViewComponentBase.Render() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\ViewComponentBase.cs:line 161
       at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:line 137
       at ASP.views_asset_searchbyassettag_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer) in d:\Projects\AMDB2010\AMDB2\Views\ASSET\SearchByAssetTag.aspx:line 41
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Control.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in d:\Projects\AMDB2010\AMDB2\Views\Shared\Site.Master:line 303
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Control.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
       at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
       at System.Web.UI.Page.Render(HtmlTextWriter writer)
       at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
       at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
       at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException:


My grid code:

<%

Html.Telerik().Grid(Model)

.Name(

 

"ASSETGrid")

 

.Columns(columns =>

{

columns.Add(c => Html.ActionLink(c.ASSET_TAG,

 

"Details", "ASSET", new { ASSET_TAG = c.ASSET_TAG, AREA_FLAG = "S" }, null))

 

.Encoded(

 

false)

 

.Title(

 

"Asset Tag");

 

 

 

//.Attributes(c => new Hash(Style => "font-weight:bold"));

 

columns.Add(c => c.ASSET_TYPE).Title(

 

"Type");

 

columns.Add(c => c.ACCEPTED_ASSET_STATUS).Title(

 

"Acpt. Status");

 

columns.Add(c => c.A_LAST_UPDATE_DATE).Title(

 

"Acpt. Date");

 

columns.Add(c => c.LOCKED_BY).Title(

 

"Locked By");

 

columns.Add(c => c.SUGGESTED_ASSET_STATUS).Title(

 

"Sugg. Date"); ;

 

columns.Add(c => c.S_LAST_UPDATE_DATE).Title(

 

"Sugg. Date").Format("yyyy-MM-dd");

 

 

})

 

 

//.Filterable()

 

.Pageable()

.Sortable().Filterable()

.Render();

%>


Thanks for help~

9 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 12 Jan 2010, 09:39 AM
Hello Will Yeung,

It seems the grid has generated a filter expression it cannot parse. Could you please paste here the URL of the filtering request which generates the exception? This would help us find what the problem is.

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Accepted
Atanas Korchev
Telerik team
answered on 13 Jan 2010, 09:22 AM
Hi Will Yeung,

Thank you for your assistance. It seems filtering cannot parse identifiers which contain underscore. Of course this is a bug. We have fixed it. To apply the fix please open
"Source\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\Parsing\FilterLexer.cs" and replace the definition of the TryParseIdentifier method with this:

private bool TryParseIdentifier(out string identifier)
{
    SkipSeparators();
 
    char currentCharacter = Peek();
 
    if (!IsIdentifier(currentCharacter))
    {
        identifier = null;
        return false;
    }
 
    StringBuilder result = new StringBuilder();
 
    identifier = Read(character => IsIdentifier(character) || character == '.', result);
 
    return true;
}
 
private static bool IsIdentifier(char character)
{
    return char.IsLetter(character) || character == '_' || character == '$' || character == '@';
}

Regards,
Atanas Korchev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Will Yeung
Top achievements
Rank 1
answered on 14 Jan 2010, 01:05 AM
Great, Atanas! It works well~
Thanks for the kind and fast support!
really helpful :)
0
Will Yeung
Top achievements
Rank 1
answered on 10 Mar 2010, 05:08 AM

Thanks! I have found another problem on filtering

When I do a filter on the following link:
http://localhost:9988/Asset/ListLocked?Area_Flag=&Asset_Tag=&Grid-orderBy=LOGICAL_NAME-asc

to filter logical_name contains "56" to the following link:
http://localhost:9988/Asset/ListLocked?Area_Flag=&Asset_Tag=&Grid-page=1&Grid-orderBy=LOGICAL_NAME-asc&Grid-groupBy=substringof%28LOGICAL_NAME%2C%2756%27%29&Grid-filter={3}

It has errors:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Expected token
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Telerik.Web.Mvc.Infrastructure.Implementation.FilterParserException: Expected token

Source Error:

Line 62:                 else
Line 63:                 {
Line 64:                     throw new FilterParserException("Expected token");
Line 65:                 }
Line 66:             }
 

Source File: D:\Projects\AMDB2010\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\Parsing\FilterLexer.cs    Line: 64

Stack Trace:

[FilterParserException: Expected token]
   Telerik.Web.Mvc.Infrastructure.Implementation.FilterLexer.Tokenize() in D:\Projects\AMDB2010\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\Parsing\FilterLexer.cs:64
   Telerik.Web.Mvc.Infrastructure.Implementation.FilterParser..ctor(String input) in D:\Projects\AMDB2010\Telerik.Web.Mvc\Infrastructure\Implementation\Filtering\Parsing\FilterParser.cs:20
   Telerik.Web.Mvc.Infrastructure.FilterDescriptorFactory.Create(String input) in D:\Projects\AMDB2010\Telerik.Web.Mvc\Infrastructure\FilterDescriptorFactory.cs:17
   Telerik.Web.Mvc.UI.GridDataProcessor.get_FilterDescriptors() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\GridDataProcessor.cs:84
   Telerik.Web.Mvc.UI.GridBoundColumnHeaderHtmlBuilder`2.Html(IHtmlNode parent) in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\Columns\GridBoundColumnHeaderHtmlBuilder.cs:95
   Telerik.Web.Mvc.UI.GridHtmlBuilder`1.HeadCellTag(GridColumnBase`1 column) in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\GridHtmlBuilder.cs:163
   Telerik.Web.Mvc.UI.<>c__DisplayClass38.<WriteHeader>b__37(GridColumnBase`1 column) in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\Grid.cs:879
   Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each(IEnumerable`1 instance, Action`1 action) in D:\Projects\AMDB2010\Telerik.Web.Mvc\Extensions\EnumerableExtensions.cs:63
   Telerik.Web.Mvc.UI.Grid`1.WriteHeader(IGridHtmlBuilder`1 builder, IHtmlNode parent) in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\Grid.cs:877
   Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer) in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\Grid\Grid.cs:631
   Telerik.Web.Mvc.UI.ViewComponentBase.Render() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\ViewComponentBase.cs:166
   Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:136
   Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.ToString() in D:\Projects\AMDB2010\Telerik.Web.Mvc\UI\ViewComponentBuilderBase.cs:147
   System.Web.HttpWriter.Write(Object obj) +27
   System.Web.Mvc.SwitchWriter.Write(Object value) +15
   System.Web.UI.HtmlTextWriter.Write(Object value) +37
   ASP.views_asset_listlocked_aspx.__RenderContent2(HtmlTextWriter __w, Control parameterContainer) in d:\Projects\AMDB2010\AMDB2\Views\ASSET\ListLocked.aspx:8
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in d:\Projects\AMDB2010\AMDB2\Views\Shared\Site.Master:477
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.UI.Control.Render(HtmlTextWriter writer) +10
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
   System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +55
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060

 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.21006; ASP.NET Version:4.0.21006.1




Here is my ListLocked.aspx:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<AMDB2.Data.DataAccess.ASSET>>" %>  
 
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">  
    ListLocked  
</asp:Content>  
 
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">  
<%= Html.Telerik().Grid(Model)  
                .Name("Grid")  
                .Columns(column =>  
                {  
                    column.Bound(c => c.ASSET_TAG);  
                    column.Bound(c => c.LOGICAL_NAME);  
                    column.Bound(c => c.LOCKED_BY);  
                      
                }  
                )  
                .Sortable()  
                .Filterable()  
%>  
 
</asp:Content>  
 
<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">  
</asp:Content>  
 
 

0
Cookie Monster
Top achievements
Rank 1
answered on 10 Mar 2010, 07:37 AM
Hello,

I've got same exception
   at Telerik.Web.Mvc.Infrastructure.Implementation.FilterLexer.Tokenize()
   at Telerik.Web.Mvc.Infrastructure.Implementation.FilterParser..ctor(String input)
   at Telerik.Web.Mvc.Infrastructure.FilterDescriptorFactory.Create(String input)
   at Telerik.Web.Mvc.UI.GridDataProcessor.get_FilterDescriptors()
   at Telerik.Web.Mvc.UI.GridBoundColumnHeaderHtmlBuilder`2.Html(IHtmlNode parent)
   at Telerik.Web.Mvc.UI.GridHtmlBuilder`1.HeadCellTag(GridColumnBase`1 column)
   at Telerik.Web.Mvc.UI.Grid`1.<>c__DisplayClass38.<WriteHeader>b__37(GridColumnBase`1 column)
   at Telerik.Web.Mvc.Extensions.EnumerableExtensions.Each[T](IEnumerable`1 instance, Action`1 action)
   at Telerik.Web.Mvc.UI.Grid`1.WriteHeader(IGridHtmlBuilder`1 builder, IHtmlNode parent)
   at Telerik.Web.Mvc.UI.Grid`1.WriteHtml(HtmlTextWriter writer)
   at Telerik.Web.Mvc.UI.ViewComponentBase.Render()
   at Telerik.Web.Mvc.UI.ViewComponentBuilderBase`2.Render()
   at ASP.views_home_index_aspx.__RenderindexContent(HtmlTextWriter __w, Control parameterContainer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Control.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Control.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
With this line:

http://localhost:4187/?UserGrid-page=1&UserGrid-orderBy=~&UserGrid-groupBy=substringof%28Id%2C%2729235%27%29&UserGrid-filter={3}

Could you please advise any fix ?



0
Atanas Korchev
Telerik team
answered on 10 Mar 2010, 08:25 AM
Hi,

I suggest you try the Q1 2010 release once we officially release it later this week. It addresses some filtering problems. If it does not please give more details about your scenario:
  1. What binding mode are you using - server or ajax?
  2. How is the problematic column defined? You can paste some code.
  3. If using ajax binding - try with server. Does it work that way?
  4. If using server binding - paste the url which is getting generated when filtering is performed.

Regards,
Atanas Korchev
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
Cookie Monster
Top achievements
Rank 1
answered on 10 Mar 2010, 08:52 AM
Hello,

I tried to download latest release, but I guess it's not available yet..

I'm using the server-side binding. Here is the URL:
http://localhost:4187/?UserGrid-page=1&UserGrid-orderBy=~&UserGrid-groupBy=substringof%28Id%2C%2729235%27%29&UserGrid-filter={3}

here is how grid is defined. Filtering fails for the Id column. Id is 'string'.

Html.Telerik().Grid(Model)
                .Name("UserGrid")
                .Columns(columns =>
                             {
                                 columns.Add(u =>
                                                 {
                                %><%=Html.ActionLink("login", "LoginAs", new { u.Id, u.FirstName, u.LastName, u.Email }, new { @class = "arrow-left" })%><%
                                                 }).Title("Action").Width(70);

                                 columns.Add(u => u.Id).Width(70);
                                 columns.Add(u => u.FirstName).Title("First Name");
                                 columns.Add(u => u.LastName).Title("Last Name");
                                 columns.Add(u => u.Email).Title("Email");
                             })
                .Pageable(paging => paging.PageSize((int)ViewData["PageSize"]).Total(100))
                .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
                .Filterable()
                .Scrollable(scrolling => scrolling.Height(450)).Render();


0
Atanas Korchev
Telerik team
answered on 10 Mar 2010, 08:54 AM
Hi Cookie Monster,

I confirm that this bug has been fixed. You can download the new release once it is available (should be till the end of the day).

Regards,
Atanas Korchev
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
Will Yeung
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Will Yeung
Top achievements
Rank 1
Cookie Monster
Top achievements
Rank 1
Share this question
or