String Methods

4 posts, 1 answers
  1. Zack
    Zack avatar
    112 posts
    Member since:
    Jun 2012

    Posted 27 Jul 2011 Link to this post

    Is it possible to do substring checks?
    Our users are used to excel and vba formulas so if they could do something like...

    Left(string,length<int>)
    Right(string,length<int>)
    Mid(string,start<int>,length<int>)

    Example usage:
    IF((Left(Column,3) = "ABC" OR Right(Column,3) = "DEF"),True,False)
  2. Zack
    Zack avatar
    112 posts
    Member since:
    Jun 2012

    Posted 27 Jul 2011 Link to this post

    Ok so I just typed "string.startsWith(string)" as an expression and it worked... very cool.

    Is there a list of all options for expressions?
    I didn't see .startsWith() in any of your documents.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 28 Jul 2011 Link to this post

    Hello Zack,

     All the functions in RadExpressionEditor's runtime are actual CLR methods, which have just been exposed in a list to make them easily discoverable for end-users. However, as every value in the RadExpressionEditor's expression is an actual CLR object, you can also call .Net methods, not only the predefined functions.

     In short, when you enter a function call expression in RadExpressionEditor, the engine tries to resolve the function from all the methods in the type of the function call operand. So when you type "myField.StartsWith("bla")", it tries to call the StartsWith method of the type of the "myField" field, which is System.String.

     Tl;dr version: even though a method or property is not exposed in RadExpressionEditor's list of available items, you can still call it in the expression, provided that the CLR type you are calling it on actually contains it.

    Regards, Yavor Georgiev
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  5. Zack
    Zack avatar
    112 posts
    Member since:
    Jun 2012

    Posted 28 Jul 2011 Link to this post

    For end users, they don't know what they can use other than the predefined functions list in the expression editor so we may consider just making a simple additional list below the editor to give them instruction on using certain methods like .startsWith() if we know they will be resolved. Maybe we filter its contents by the field type they have selected in the editor.
Back to Top