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

RadGrid GridCalculatedColumn Expression Digit Expected Exception

3 Answers 111 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kuya
Top achievements
Rank 1
Kuya asked on 30 Sep 2016, 02:42 AM

Hi! I have a project with a RadGrid table showing information. I have this snippet of code inside it:

<telerik:GridCalculatedColumn DataFields="Stake,TotalGames" Expression="iif({1} = 0, 0, {0}/{1})"
FilterControlWidth="40px" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right"
UniqueName="AvgBet" DataFormatString="{0:N2}" HeaderText="Avg Bet (Real)" DataType="System.Decimal"
Aggregate="Avg" FooterStyle-HorizontalAlign="Right" />

 

Now, this works with English and Chinese locale settings. However, when we set the locale to ES, the formatting changes (from 0.00 to 0,00), and we believe that the problem is coming from the Expression in the code. We think that it might be that the values were interpreted as string? It works with English and Chinese locale (maybe because of the standard number decimal formatting).

 

We have tried these approaches but to no avail:

1. On binding data (OnNeedDataSource), we modify the locale like this:

 if (dtable.Locale.ToString().Substring(0,2) == "es")
      {
        System.Globalization.CultureInfo myCultureInfo = new System.Globalization.CultureInfo("en-gb");
        dtable.Locale = myCultureInfo;
      }

However, this still shows the same problem. 

 

2. We tried this as well (IsLocalizationLanguageRespected set to true or false): 

<telerik:RadGrid ID="grdSessions" runat="server" GridLines="None" AllowFilteringByColumn="True"
          PageSize="50" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" 
          GroupHeaderItemStyle-Font-Bold="true" GroupHeaderItemStyle-ForeColor="Black"
          EnableHeaderContextMenu="True" OnNeedDataSource="grdSessions_NeedDataSource"
          Width="98%" ShowFooter="true" IsLocalizationLanguageRespected="false">

We are not sure how to approach this one next. Can you give me suggestions on how to proceed? 

 

Thank you!
Psalm

3 Answers, 1 is accepted

Sort by
0
Kuya
Top achievements
Rank 1
answered on 30 Sep 2016, 03:00 AM

Just to add, the exception that I am getting is Digit is Expected. Here is the log of the error:

 

[ParseException: Digit expected] Telerik.Web.UI.ExpressionParser.ValidateDigit() +98 Telerik.Web.UI.ExpressionParser.NextToken() +1032 Telerik.Web.UI.ExpressionParser.ParseComparison() +71 Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +31 Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +31 Telerik.Web.UI.ExpressionParser.ParseExpression() +22 Telerik.Web.UI.ExpressionParser.ParseArguments() +57 Telerik.Web.UI.ExpressionParser.ParseArgumentList() +56 Telerik.Web.UI.ExpressionParser.ParseIif() +29 Telerik.Web.UI.ExpressionParser.ParseIdentifier() +216 Telerik.Web.UI.ExpressionParser.ParsePrimary() +17 Telerik.Web.UI.ExpressionParser.ParseUnary() +325 Telerik.Web.UI.ExpressionParser.ParseMultiplicative() +33 Telerik.Web.UI.ExpressionParser.ParseAdditive() +33 Telerik.Web.UI.ExpressionParser.ParseComparison() +35 Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +31 Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +31 Telerik.Web.UI.ExpressionParser.ParseExpression() +22 Telerik.Web.UI.ExpressionParser.ParseNew() +156 Telerik.Web.UI.ExpressionParser.ParseIdentifier() +249 Telerik.Web.UI.ExpressionParser.ParsePrimary() +17 Telerik.Web.UI.ExpressionParser.ParseUnary() +325 Telerik.Web.UI.ExpressionParser.ParseMultiplicative() +33 Telerik.Web.UI.ExpressionParser.ParseAdditive() +33 Telerik.Web.UI.ExpressionParser.ParseComparison() +35 Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +31 Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +31 Telerik.Web.UI.ExpressionParser.ParseExpression() +22 Telerik.Web.UI.ExpressionParser.Parse(Type resultType) +25 Telerik.Web.UI.DynamicExpression.ParseLambda(ParameterExpression[] parameters, Type resultType, String expression, Object[] values) +68 Telerik.Web.UI.GridDynamicQueryable.Select(IQueryable source, String selector, Object[] values) +73 Telerik.Web.UI.GridDataTableFromEnumerable.FillData35() +2684 Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +803 Telerik.Web.UI.GridResolveEnumerable.Initialize() +45 Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +35 Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, DataView dataView, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +345 Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +150 Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +220 Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +428 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +97 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +165 Telerik.Web.UI.GridTableView.PerformSelect() +23 Telerik.Web.UI.GridTableView.DataBind() +363 Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +3207 Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +150 System.Web.UI.Control.LoadRecursive() +68 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

0
Kuya
Top achievements
Rank 1
answered on 30 Sep 2016, 03:01 AM

To add, here is the exception:

[ParseException: Digit expected] Telerik.Web.UI.ExpressionParser.ValidateDigit() +98 Telerik.Web.UI.ExpressionParser.NextToken() +1032 Telerik.Web.UI.ExpressionParser.ParseComparison() +71 Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +31 Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +31 Telerik.Web.UI.ExpressionParser.ParseExpression() +22 Telerik.Web.UI.ExpressionParser.ParseArguments() +57 Telerik.Web.UI.ExpressionParser.ParseArgumentList() +56 Telerik.Web.UI.ExpressionParser.ParseIif() +29 Telerik.Web.UI.ExpressionParser.ParseIdentifier() +216 Telerik.Web.UI.ExpressionParser.ParsePrimary() +17 Telerik.Web.UI.ExpressionParser.ParseUnary() +325 Telerik.Web.UI.ExpressionParser.ParseMultiplicative() +33 Telerik.Web.UI.ExpressionParser.ParseAdditive() +33 Telerik.Web.UI.ExpressionParser.ParseComparison() +35 Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +31 Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +31 Telerik.Web.UI.ExpressionParser.ParseExpression() +22 Telerik.Web.UI.ExpressionParser.ParseNew() +156 Telerik.Web.UI.ExpressionParser.ParseIdentifier() +249 Telerik.Web.UI.ExpressionParser.ParsePrimary() +17 Telerik.Web.UI.ExpressionParser.ParseUnary() +325 Telerik.Web.UI.ExpressionParser.ParseMultiplicative() +33 Telerik.Web.UI.ExpressionParser.ParseAdditive() +33 Telerik.Web.UI.ExpressionParser.ParseComparison() +35 Telerik.Web.UI.ExpressionParser.ParseLogicalAnd() +31 Telerik.Web.UI.ExpressionParser.ParseLogicalOr() +31 Telerik.Web.UI.ExpressionParser.ParseExpression() +22 Telerik.Web.UI.ExpressionParser.Parse(Type resultType) +25 Telerik.Web.UI.DynamicExpression.ParseLambda(ParameterExpression[] parameters, Type resultType, String expression, Object[] values) +68 Telerik.Web.UI.GridDynamicQueryable.Select(IQueryable source, String selector, Object[] values) +73 Telerik.Web.UI.GridDataTableFromEnumerable.FillData35() +2684 Telerik.Web.UI.GridDataTableFromEnumerable.FillData() +803 Telerik.Web.UI.GridResolveEnumerable.Initialize() +45 Telerik.Web.UI.GridResolveEnumerable.EnsureInitialized() +35 Telerik.Web.UI.GridEnumerableFromDataView..ctor(GridTableView owner, DataView dataView, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +345 Telerik.Web.UI.GridDataSourceHelper.CreateGridEnumerable(GridTableView owner, IEnumerable enumerable, Boolean caseSensitive, Boolean autoGenerateColumns, GridColumnCollection presentColumns, String[] additionalField, Boolean retrieveAllFields, Boolean enableSplitHeaderText) +150 Telerik.Web.UI.GridTableView.get_ResolvedDataSource() +220 Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +428 System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +97 System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +165 Telerik.Web.UI.GridTableView.PerformSelect() +23 Telerik.Web.UI.GridTableView.DataBind() +363 Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason) +3207 Telerik.Web.UI.RadGrid.OnLoad(EventArgs e) +150 System.Web.UI.Control.LoadRecursive() +68 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Control.LoadRecursive() +165 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

0
Konstantin Dikov
Telerik team
answered on 04 Oct 2016, 02:04 PM
Hello Kuya,

Please try the following expression instead, which should resolve the error that you are receiving:
Expression="iif(({1} = 0), (0), {0}/{1})"

I have tested this with "es-ES" culture and it fixes the issue on my side.

Looking forward to your reply with the result.


Regards,
Konstantin Dikov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
General Discussions
Asked by
Kuya
Top achievements
Rank 1
Answers by
Kuya
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or