Members
ColumnLeaf
Prototype additions object for extending FilterLeaf
.
Resulting object is similar to FilterLeaf
except:
- The
operand
property names another column rather than contains a literal. - Operators are limited to equality, inequalities, and sets (IN/NOT IN). Omitted are the string and pattern scans (BEGINS/NOT BEGINS, ENDS/NOT ENDS, CONTAINS/NOT CONTAINS, and LIKE/NOT LIKE).
Properties:
Name | Type | Description |
---|---|---|
identifier |
string | Name of column (member of data row object) to compare against this column (member of data row object named by |
converters
Properties:
Name | Type | Description |
---|---|---|
number |
converter | |
int |
converter | synonym of |
float |
converter | synonym of |
date |
converter | |
string |
converter |
dateConverter :converter
Type:
editors
Hash of constructors for objects that extend from FilterLeaf
, which is the Default
member here.
Add additional editors to this object (in the prototype) prior to instantiating a leaf node that refers to it. This object exists in the prototype and additions to it will affect all nodes that don't have their an "own" hash.
If you create an "own" hash in your instance be sure to include the default editor, for example: { Default: FilterTree.prototype.editors.Default, ... }
. (One way of overriding would be to include such an object in an editors
member of the options object passed to the constructor on instantiation. This works because all miscellaneous members are simply copied to the new instance. Not to be confused with the standard option editor
which is a string containing a key from this hash and tells the leaf node what type to use.)
numberConverter :converter
Type:
treeOperators :object
A hash of treeOperator
objects.
Type:
- object
Methods
addEditor(keyopt, extopt, BaseEditoropt) → {FillterLeaf}
An extension is a hash of prototype overrides (methods, properties) used to extend the default editor.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
string |
<optional> |
'Default' | Nme of the new extension given in |
ext |
object |
<optional> |
An extension hash |
|
BaseEditor |
FilerLeaf |
<optional> |
this.editors.Default | Constructor to extend from. |
Returns:
A new class extended from BaseEditor
-- which is initially FilterLeaf
but may itself have been extended by a call to .addEditor('Default', extension)
.
- Type
- FillterLeaf
cleanUpAndMoveOn()
change
event handler for all form controls.
Rebuilds the operator drop-down as needed.
Removes error CSS class from control.
Adds warning CSS class from control if blank; removes if not blank.
Adds warning CSS class from control if blank; removes if not blank.
Moves focus to next non-blank sibling control.
This:
copy(el, textopt) → {undefined|string}
- Trim the text in the given input element
- select it
- copy it to the clipboard
- deselect it
- return it
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
el |
HTMLElement | HTMLTextAreaElement | |||
text |
string |
<optional> |
el.value | Text to copy. |
Returns:
Trimmed text in element or undefined if unable to copy.
- Type
- undefined | string
copyAll(containingElopt, prefixopt, separatoropt, suffixopt, transformeropt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
containingEl |
HTMLElement |
<optional> |
document | |
prefix |
string |
<optional> |
'' | |
separator |
string |
<optional> |
'' | |
suffix |
string |
<optional> |
'' | |
transformer |
function |
<optional> |
multiLineTrim | Function to transform each input control's text value. |
filterCount() → {number}
Returns:
Number of filters (terminal nodes) defined in this subtree.
- Type
- number
firstChildOfType(selector)
Work-around for this.el.querySelector(':scope>' + selector)
because :scope
not supported in IE11.
Parameters:
Name | Type | Description |
---|---|---|
selector |
string |
getOpMenu(columnName) → {undefined|Array.<menuItem>}
This:
Parameters:
Name | Type | Description |
---|---|---|
columnName |
string |
Returns:
- Type
- undefined | Array.<menuItem>
getProperty(columnName, propertyName, mixinopt) → {object}
Get the node property.
Priority ladder:
- Schema property.
- Mixin (if given).
- Node property is final priority.
This:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
columnName |
string | ||
propertyName |
string | ||
mixin |
function | boolean |
<optional> |
Optional function or value if schema property undefined. If function, called in context with |
Returns:
- Type
- object
initialize(optionsopt)
Create a new node or subtree.
Typically used by the application layer to create the entire filter tree; and internally, recursively, to create each node including both subtrees and leaves.
Node properties and options: Nodes are instantiated with:
- Certain required properties which differ for subtrees and leaves.
- Arbitrary non-standard option properties are defined on the
options
object (so long as their names do not conflict with any standard options) and never persist. - Certain standard options properties as defined in the
optionsSchema
hash, come from various sources, as prioritized as follows:options
object; does not persiststate
; object; persistsparent
object; persistsdefault
object; does not persist
Notes:
- "Persists" means output by
getState()
. - The
parent
object is generated internally for subtrees. It allows standard options to inherit from the parent node. - The
default
object comes from thedefault
property, if any, of theschema object
for the standard option in question. Note that once defined, subtrees will then inherit this value. - If not defined by any of the above, the standard option remains undefined on the node.
Query Builder UI support: If your app wants to make use of the generated UI, you are responsible for inserting the top-level .el
into the DOM. (Otherwise just ignore it.)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
FilterTreeOptionsObject |
<optional> |
The node state; or an options object possibly containing
|
makeOpMenu(columnName)
This:
Parameters:
Name | Type | Description |
---|---|---|
columnName |
string |
mixInNonstandardOptions(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
mixInStandardOptions(state, options)
Create each standard option from when found on the options
or state
objects, respectively; or if not an "own" option, on the parent
object or from the options schema default (if any)
Parameters:
Name | Type | Description |
---|---|---|
state |
||
options |
Type Definitions
converter
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
toType |
function | Returns input value converted to type. Fails silently. |
failed |
function | Tests input value against type, returning |
filterLeafViewObject
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
column |
HTMLElement | A drop-down with options from the |
operator |
A drop-down with options from |
|
operand |
An input element, such as a drop-down or a text box. |
FilterTreeGetStateOptionsObject
Object containing options for producing a state object.
State is commonly used for two purposes:
- To persist the filter state so that it can be reloaded later.
- To send a query to a database engine.
Type:
- object
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
syntax |
boolean |
<optional> |
'object' | A case-sensitive string indicating the expected type and format of a state object to be generated from a filter tree. One of:
|
FilterTreeOptionsObject
Type:
- object
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
schema |
Array.<menuItem> |
<optional> |
A default list of column names for field drop-downs of all descendant terminal nodes. Overrides
|
|
ownSchema |
Array.<menuItem> |
<optional> |
A default list of column names for field drop-downs of immediate descendant terminal nodes only. Overrides Although both
|
|
state |
FilterTreeStateObject |
<optional> |
A data structure that describes a tree, subtree, or leaf (terminal node). If undefined, loads an empty filter, which is a |
|
editor |
function |
<optional> |
'Default' | The name of the conditional expression's UI "editor." This name must be registered in the parent node's |
parent |
FilterTree |
<optional> |
Used internally to insert element when creating nested subtrees. The only time it may be (and must be) omitted is when creating the root node. |
|
cssStylesheetReferenceElement |
string | HTMLElement |
<optional> |
passed to cssInsert |
FilterTreeSetStateOptionsObject
Type:
- object
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
syntax |
boolean |
<optional> |
'auto' | Specify parser to use on
|
FilterTreeStateObject
State with which to create a new node or replace an existing node.
A string or plain object that describes a filter-tree node. If a string, it is parsed into an object by FilterNode~parseStateString
. (See, for available overloads.)
The resulting object may be a flat object that describes a terminal node or a childless root or branch node; or may be a hierarchical object to define an entire tree or subtree.
In any case, the resulting object may have any of the following properties:
Type:
- object | string
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
schema |
Array.<menuItem> |
<optional> |
See |
|
editor |
string |
<optional> |
'Default' | See |
misc |
Other miscellaneous properties will be copied directly to the new
The constructor auto-detects
|
FilterTreeValidationOptionsObject
Type:
- object
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
throw |
boolean |
<optional> |
false | Throw (do not catch) |
alert |
boolean |
<optional> |
false | Announce error via window.alert() before returning. |
focus |
boolean |
<optional> |
false | Place the focus on the offending control and give it error color. |
operationReducer(p, q) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
p |
boolean | |
q |
boolean |
Returns:
The result of applying the operator to the two parameters.
- Type
- boolean
optionsSchemaObject
Standard option schema
Standard options are automatically added to nodes. Data sources for standard options include options
, state
, parent
and default
(in that order). Describes standard options through various properties:
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
ignore |
boolean |
<optional> |
Do not automatically add to nodes (processed elsewhere). |
own |
boolean |
<optional> |
Do not automatically add from |
rootBound |
boolean |
<optional> |
Automatically add to root node only. |
default |
* |
<optional> |
This is the default data source when all other strategies fail. |
relationalOperator
Type:
- object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
test |
relationalTest | ||
make |
relationalSyntax | ||
type |
string |
<optional> |
relationalSyntax(a, b) → {string}
Generates human-readable string syntax from conditionals.
The type of the parameters will always be homogeneous and is determined by FilterLeaf's typing algorithm, which attempts to convert the data in it's natural string form to the type sepcified by the field's type, if defined. If both sides cannot be converted, it falls back to strings.
Parameters:
Name | Type | Description |
---|---|---|
a |
string | number | Date | Left side of dyadic conditional expression. |
b |
string | number | Date | Right side of dyadic conditional expression. |
Returns:
Syntax for that expressions a specific relationship between a
and b
.
- Type
- string
relationalTest(a, b) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
a |
string | number | Date | Left side of dyadic conditional expression. |
b |
string | number | Date | Right side of dyadic conditional expression. |
Returns:
The result of comparing a
and b
.
- Type
- boolean
sqlIdQtsObject
On a practical level, the useful characters are:
- SQL-92 standard: "double quotes"
- SQL Server: "double quotes" or [square brackets]
- mySQL: `tick marks`
Type:
- object
Properties:
Name | Type | Description |
---|---|---|
beg |
string | The open quote character. |
end |
string | The close quote character. |
treeOperator
Each treeOperator
object describes two things:
- How to take the test results of n child nodes by applying the operator to all the results to "reduce" it down to a single result.
- How to generate SQL WHERE clause syntax that applies the operator to n child nodes.
Type:
- obejct
Properties:
Name | Type | Description |
---|---|---|
reduce |
operationReducer | |
seed |
boolean | - |
abort |
boolean | - |
negate |
boolean | - |
SQL.op |
string | - |
SQL.beg |
string | - |
SQL.end |
string | - |