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

String Methods

3 Answers 89 Views
ExpressionEditor
This is a migrated thread and some comments may be shown as answers.
Guru
Top achievements
Rank 2
Guru asked on 27 Jul 2011, 09:33 PM
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)

3 Answers, 1 is accepted

Sort by
0
Guru
Top achievements
Rank 2
answered on 27 Jul 2011, 09:39 PM
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.
0
Accepted
Yavor Georgiev
Telerik team
answered on 28 Jul 2011, 09:43 AM
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!

0
Guru
Top achievements
Rank 2
answered on 28 Jul 2011, 02:23 PM
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.
Tags
ExpressionEditor
Asked by
Guru
Top achievements
Rank 2
Answers by
Guru
Top achievements
Rank 2
Yavor Georgiev
Telerik team
Share this question
or