Field Multiplication Problem

7 posts, 1 answers
  1. Gerald
    Gerald avatar
    6 posts
    Member since:
    Nov 2010

    Posted 17 Jun 2011 Link to this post

    I have problem multiplying a field by a decimal number. If I multipley a field by a whole number such as 2 it works fine. If I type 2.5 then my expression gets underlined, the result preview is blank and the OK button is grayed out.

    I am able to reproduce this problem using the demo on the Telerik site:

    http://demos.telerik.com/silverlight/#ExpressionEditor/FirstLook

    Try editing the expression in the demo and try multiplying the UnitPrice field by 2.5. The expression looks like this:

     UnitPrice *2.5

    Any help with this is greatly appreciated.

    Thanks,
    -Gerry
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 17 Jun 2011 Link to this post

    Hi Gerry,

     Can you try "UnitPrice * 2,5" instead? 

    Regards,
    Vlad
    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
  3. DevCraft banner
  4. Gerald
    Gerald avatar
    6 posts
    Member since:
    Nov 2010

    Posted 17 Jun 2011 Link to this post

    We I use  "UnitPrice *2,5" the result is the same as " UnitPrice *2" so the decimal portion is ignored.
  5. Answer
    Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 17 Jun 2011 Link to this post

    Hello Gerald,

    I'm the guy that has written the parser behind the Expression Editor component. I have just looked at how we handle the decimal separator and here is the exact code from our source:
    private static NumberFormatInfo NumberFormatInfo
    {
        get
        {
            return NumberFormatInfo.InvariantInfo;
        }
    }
     
    private static readonly char DecimalSeparator = NumberFormatInfo.NumberDecimalSeparator.FirstOrDefault();

    This means that we are using the invariant culture decimal number separator, which is ".". We have done it this way so that a given string expression is valid for all clients no matter of their local machine regional and language settings.

    The actual problem in your case is that binary operator (*) is not defined for decimal (UnitPrice field is decimal) and double (2.5 is parsed as double) numbers. If you mouse over the red error underline you will see this problem reported in a tool tip. What we can do under the hood is to create a conversion for the entered double to a decimal number. This will bring a precision lost in some rear cases, but will work in the general case like yours. What you can currently try out is to enter this one: UnitPrice * 2.5e0. This will signal our parser that 2.5 is a decimal number and the runtime will be able to multiply two decimal numbers.

    Thanks for bringing this to our attention. Your feedback is greatly appreciated.

    Best wishes,
    Stefan Dobrev
    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
  6. Gerald
    Gerald avatar
    6 posts
    Member since:
    Nov 2010

    Posted 17 Jun 2011 Link to this post

    Thanks, that worked.

    Do you know when the fix that you mentioned will be released? We are planning on using the ExpressionEditor in our September release. We would need this fix by then because I don't think that we can expect users to type decimals as 2.5e0 :)

    -Gerry
  7. Stefan Dobrev
    Admin
    Stefan Dobrev avatar
    790 posts

    Posted 20 Jun 2011 Link to this post

    Hello Gerald,

    This behavior will be available in one of our next internal releases as well in our upcoming official release of the controls. I have also created a PITS item (#6563) that you can use to track the progress status on your own.

    All the best,
    Stefan Dobrev
    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
  8. Nathaniel
    Nathaniel avatar
    68 posts
    Member since:
    Nov 2010

    Posted 27 Oct 2011 Link to this post

    What type of Variables do the predefined functions accept? Im trying to use the Pow() function.  It says it takes Number, Numer.  But it wont let me use two of my Fields, which are of type Decimal. 


    In the demo  http://demos.telerik.com/silverlight/#ExpressionEditor/FirstLook

    I can change the expression column expresiion to be Pow(UnitPrice, UnitPrice).    What is the data type of UnitPrice?

Back to Top
DevCraft banner