new FilterLeaf()
An object that represents a conditional expression node in a filter tree.
This object represents a conditional expression. It is always a terminal node in the filter tree; it has no child nodes of its own.
A conditional expression is a simple dyadic expression with the following syntax in the UI:
column operator operand
where:
- column is the name of a column from the data row object
- operator is the name of an operator from the node's operator list
- operand is a literal value to compare against the value in the named column
NOTE: The ColumnLeaf
extension of this object has a different implementation of operand which is: The name of a column from which to fetch the compare value (from the same data row object) to compare against the value in the named column. See Extending the conditional expression object in the readme.
The values of the terms of the expression above are stored in the first three properties below. Each of these three properties is set either by setState()
or by the user via a control in el
. Note that these properties are not dynamically bound to the UI controls; they are updated by the validation function, invalid()
.
See also the properties of the superclass: FilterNode
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
column |
string | Name of the member in the data row objects against which |
||
operator |
string | Operator symbol. This must match a key in the |
||
operand |
string | Value to compare against the the member of data row named by |
||
name |
string | Used to describe the object in the UI so user can select an expression editor. |
||
type |
string |
<optional> |
'string' | The data type of the subexpression if neither the operator nor the column schema defines a type. |
el |
HTMLElement | A |
||
view |
filterLeafViewObject | A hash containing direct references to the controls in |
Methods
createView()
Create a new view.
This new "view" is a group of HTML Element
controls that completely describe the conditional expression this object represents. This method creates the view, setting this.el
to point to it, and the members of this.view
to point to the individual controls therein.
getState(optionsopt)
For 'object'
and 'JSON'
note that the subtree's version of getState
will not call this leaf version of getState
because the former uses unstrungify()
and JSON.stringify()
, respectively, both of which recurse and call toJSON()
on their own.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
object |
<optional> |
'object' | See the subtree version of |
invalid() → {undefined}
Called by the parent node's invalid()
method, which catches the error thrown when invalid.
Also performs the following compilation actions:
- Copies all
this.view
' values from the DOM to similarly named properties ofthis
. - Pre-sets
this.op
andthis.converter
for use intest
's tree walk.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options.throw |
boolean |
<optional> |
false | Throw an error if missing or invalid value. |
options.focus |
boolean |
<optional> |
false | Move focus to offending control. |
Returns:
This is the normal return when valid; otherwise throws error when invalid.
- Type
- undefined
makeElement(menuopt, promptopt, sortopt)
HTML form controls factory.
Creates and appends a text box or a drop-down.
Defined on the FilterTree prototype for access by derived types (alternate filter editors).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
menu |
Array.<menuItem> |
<optional> |
Overloads:
|
|
prompt |
null | string |
<optional> |
'' | Adds an initial |
sort |
<optional> |
Returns:
The new element.