SMART datagrid v.1 > Concepts

Back  Forward

Concepts.Expression Overivew

SMART datagrid Expression is being used to display and handle the data in the grid. Although it contains several special operators to handle the value, it has been defined and implemented as simple as possible to be used in big data set. 

In particular, since the priority of relational, comparison, logical operator has been integrated into one in the existing language, it must be enclosed in brackets if necessary. Expression text except the value is not case sensitive. 

It is used in EditValidation.expression, DynamicStyle.expression, etc. 

1. Syntax Grammer
Expression ::= ComparisonExpression (LogicalOperator ComparisonExpression)*
ComparisonExpression ::= SimpleExpression (ComparisonOperator SimpleExpression | SetOperator ExpressionList)*
ExpressionList ::= "()" | "(" SimpleExpression ("," SimpleExpression)* ")"
SimpleExpression ::= Term *(AddingOperator Term)
Term ::= Factor (MultiplyingOperator Factor)*
Factor ::= "(" Expression ")" | Variable | Constant | Converting Factor | Unary Factor
Constant ::= Unsigned Number | Charactor String | null | empty | defined | nan | true | false
2. Operators

It displays from a high priority. There is no priority between operators involved in the same group. If you want to give priority by force, you should enclose in brackets. The priority of Set Operator and Comparison Operator is the same. 

Table-1  Constants
OperatorExplanationExample
nullJavaScript null. Use is, is not as operand only.value is null
emptyEmpty value. undefined, null, Empty String. Use is, is not as operand only.value is empty
definedThe value not JavaScript undefiend. Use is, is not as operand only.value is defined
nanJavaScript NaN. Use is, is not as operand only.value is nan
true, falseJavaScript true, falsevalue == true
Table-2  Converting operator
OperatorExplanationExampleResult
strConvert to Stringstr 100'100'
numConvert to Numbernum '199'199
intConvert to Integerint '199.9'int
dateConvert to Date. Compare to Date.getTime() value when compare the converted two values.date '2010/11/11' <= local date
date('2010-11-11') <= utc date
date('2010-11-11T00:00:00+09:00')
It should be the string which can be transferred by JavaScript Date Object Constructor. In particular, in order to run data comparison operation including time value in all browsers equally, you must use ISO standard format including time zone.
Please refer to Date.parse function.
boolConvert to Booleanbool '1'true
Table-3  Unaray Operator
OperatorExplanationExampleResult
not, !Denialnot true, ! truefalse
-Negative -100-100
+Positive+100100
lenString Lengthlen 'abcd'4
randRandom Integer greater than 0 and less than parameterrand 10015
srandAscill string of the length specified by parametersrand 7'xfeDfdG'
lowerChange the string specified by parameter to lower case stringlower 'AbcdEf''abcdef'
upperChange the string specified by parameter to upper case stringupper 'AbcdEf''ABCDEF'
Table-4  Multiplying Operator
OperatorExplanationExampleResult
*Multiplication11 * 222
/Division5 / 22.5
divInteger Division5 div 22
% (mod)Remainder5 % 2, 5 mod 21
Table-5  Adding Operator
OperatorExplanationExampleResult
+Plus11 + 213
-Minus5 - 23
Table-6  Comparison Operator
OperatorExplanationExampleResult
==, !=, <, <=, >, >=Comparisontrue|false
isComparisonvalue is null, value is empty, value is defined, value is nantrue|false
is notComparisonvalue is not null, value is not empty, value is not defined, value is not nantrue|false
match, not matchRegular expressionvalue match '[^d.-+]'true|false
imatch, not imatchRegular expression not case sensitivevalue match '[^d.-+]'true|false
like, not likeText comparisonvalue like '%abc%', value not like '%abc', value like 'abc%true|false
ilike, not ilikeText comparison not case sensitivevalue ilike '%abc%', value not ilike '%abc', value ilike 'abc%true|false

*The priority of Set operators are the same as Comparison operators. 

Table-7  Set Operator
OperatorExplanationExampleResult
in, not inInclude3 in (1, 2 3), value not in ('a', 'b', 'c')
Right operand should be a list of being enclosed in brackets ('(', ')') and items being separated by comma (',').
true|false
Table-8  Logical Operator
OperatorExplanationExampleResult
&&Logical AND(And)true && falsefalse
||Logical OR(Or)true || falsetrue
Code -1
    grid.setColumns([{
        fieldName: 'product_id',
        styles: [{
            expression: "value > 1000",
            styles: {
                background: "#01ff0000",
                ...
            }
        }]
    ], {
        ...
    }]);
Code -2
    column.setValidations([{
        "expression": "value is not empty",
        "level": DataLudi.ValidationLevel.ERROR,
        "message": strings["CommCodeMsg"]
    }]);
See Also
DynamicStyle
EditValidation
DataColumn.dynamicStyles
GridBody.dynamicStyles
Examples
Column Dynamic Styles
Default Dynamic Styles
Cell Validation
Row Validation