Package com.smartgwt.client.docs
Interface XmlCriteriaShorthand
public interface XmlCriteriaShorthand
All rules described in this topic are applied any time a property is of type
AdvancedCriteria (in both Component XML and JavaScript
component creation)
and any API declares an AdvancedCriteria param.
A shorthand format for AdvancedCriteria is supported for
simple criteria
where the outer criterion is assumed to be an "and" operator:
<!-- Simple format --> <criteria fieldName="restrictAge" operator="equals" value="true"/>This is equivalent to:
<!-- Normal format -->
<criteria _constructor="AdvancedCriteria operator="and">
<criteria>
<criterion fieldName="restrictAge" operator="equals" value="true"/>
</criteria>
</criteria>
Additionally these defaults are used allowing to simplify AdvancedCriteria declaration:
-
operator="and" default is used if criteria is present at the same level
operator="equals" default is used if fieldName is present at the same level
value="true" default is used if operator="equals" default was applied
conditionally enable a
form button:
<!-- Simple format --> <enableWhen fieldName="CustomerGrid.anySelected"/>Full equivalent:
<!-- Normal format -->
<enableWhen _constructor="AdvancedCriteria operator="and">
<criteria>
<criterion fieldName="CustomerGrid.anySelected" operator="equals" value="true"/>
</criteria>
</enableWhen>
Another example shows all defaults usage, significantly shortening AdvancedCriteria declaration
for
boolean dynamic property (see full setup in
Boolean Dynamic Properties example):
<!-- Simple format -->
<trueWhen>
<criteria fieldName="settingsForm/values/exportFieldWidths" />
<criteria fieldName="settingsForm/values/exportAs" operator="inSet" >
<value>xls</value>
<value>ooxml</value>
</criteria>
</trueWhen>
Full equivalent:
<!-- Normal format -->
<trueWhen>
<AdvancedCriteria operator="and">
<criteria>
<criterion fieldName="settingsForm/values/exportFieldWidths" operator="equals" value="true"/>
<criterion fieldName="settingsForm/values/exportAs" operator="inSet" >
<value>xls</value>
<value>ooxml</value>
</criterion>
</criteria>
</AdvancedCriteria>
</trueWhen>
JS example:
// Simple format
{fieldName: "restrictAge"}
// Normal format
{
_constructor: "AdvancedCriteria",
operator: "and",
criteria: [
{fieldName: "restrictAge", operator: "equals", value: true}
]
}