addClause(name, value, op, relOp, replace)
JavaScript API Reference/Ab.view.Resriction object
addClause(name, value, op, relOp, replace)
Adds a clause to the restriction object.
Parameters:
-
name
(String): field name to compare -
value
(String): field value to compare -
op
(String): (optional) operation code, default is "=" (equal). Supported operations are:
• =
• <
• <=
• >
• >=
• <>
• LIKE
• IS NULL
• IS NOT NULL -
relOp (
Relational operation code): determines how individual clauses are combined to form a complex restriction. Supported values are:- AND
- OR
- )AND(
- )OR(
-
replace
(boolean): (optional) if true, existing clause for the same field must be replaced. By default, existing clauses are not replaced.
Example:
Create a custom restriction based on the selected date range.
var form = View.getControl('',
'console');
var dateRequestedFrom = form.getFieldValue('wr.date_requested.from');
var dateRequestedTo = form.getFieldValue('wr.date_requested.to');
var restriction = new Ab.view.Restriction();
restriction.addClause(
'wr.date_requested',
'#Date%' + dateRequestedFrom + '%',
'>=');
restriction.addClause(
'wr.date_requested',
'#Date%' + dateRequestedTo + '%',
'<=');
var grid = View.getControl('', 'projects');
grid.refresh(restriction);
Example:
v<!-- (bl_id=HQ and area < 50) or (bl_id=HQ and area > 250) -->
<restriction type="parsed">
<clause op="=" value="HQ" name="bl_id" table="rm"/>
<clause relop="and" op="<" value="50.0" name="area" table="rm"/>
<clause relop=")or(" op="=" value="HQ" name="bl_id" table="rm"/>
<clause relop="and" op=">" value="250.0" name="area" table="rm"/>
</restriction>