Table of Contents

EQ.core namespace

Contains different classes and functions for managing core EasyQuery objects: data model, query, entities, attributes, operators, etc.

Variables

texts

Type:Object
Default:{Entities: {}, Attributes: {}, Operators: {}}
Contains the text strings that are used in the UI divided by 3 lists. By default the internal (English) list of strings is used.
Note:These lists are usually used to localize the UI.

constLists

Type:Object
Contains the constants used to work with date/time and boolean values.

Functions

getText

Returns:
(String)
Text of the resource defined by key
Returns localized text by the key defined in parameters
Parameters:
key
Type:String
The key of the resource string.
Code examples:
Here we get the text of the resource string assigned to CmdClickToAddCondition key

var text = EQ.core.getText("CmdClickToAddCondition")

Classes

DataModel class

Represents a data model.

Methods

getObject
Gets internal model object.
setObject
Sets internal model object. Accepts model representation in JSON format as well.
Parameters:
data
Type:Object | String
Internal model representation as pure JavaScript object or as JSON string
isEmpty
Returns true if current model is empty (does not contain any entity)
isEmpty
Returns root entity object
getAttributById
Returns:
(Object)
An attribute.
Gets entity attribute by its ID. This function runs through all attributes inside specified model (it's root entity and all its sub-entities). Returns null if attribute is not found.
Parameters:
attrId
Type:String
Attribute ID
getEntityAttrById
Returns:
(Object)
An attribute.
Gets entity attribute by its ID. This function runs through all attributes inside specified entity and all its sub-entities. Returns null if attribute is not found.
Parameters:
entity
Type:Object
Entity object to search in
attrId
Type:String
Attribute ID
getFirstUICAttrInEntity
Returns:
(Object)
An attribute.
Gets first “UIC” attribute in specified entity (UIC stands for “use in conditions” - so such attribute can be used in conditions) Returns null if attribute is not found.
Parameters:
entity
Type:Object
Entity object to search our attribute in.
runThroughEntities
Scans model's entity tree and calls the callback functions for each attribute and entity.
Parameters:
processAttribute
Type:Function
The callback function which is called for each attribute in model's entity tree. The processed attribute is passed in the first function parameter.
processEntity
Type:Function
The callback function which is called for each entity in tree. The processed entity is passed in the first function parameter.
findOperatorById
Returns:
(Object)
An operator.
Finds operator in model by its ID. This function runs through all operators inside specified model and returns the one with specified ID. Returns null if operator is not found.
Parameters:
operatorId
Type:String
Operator ID
getOperatorById
Returns:
(Object)
An operator.
Finds operator in model by its ID. This function runs through all operators inside specified model and returns the one with specified ID. Returns special NullOperator object if operator is not found.
Parameters:
operatorId
Type:String
Operator ID

Query class

Represents internal query structure.

Methods

getObject
Gets internal query object.
setObject
Sets internal query object. Accepts query representation in JSON format as well.
Parameters:
data
Type:Object | String
Internal query representation as pure JavaScript object or as JSON string
getModel
Gets DataModel object associated with this query.
setModel
Sets DataModel object associated with this query.
Parameters:
model
Type:Object
A DataModel object
toJSON
Returns JSON representation of this query.
isEmptyConditions
Returns true if query does not contain any condition.
clear
Clears query (all conditions and columns).
clearColumns
Clears all columns in query.
clearConditions
Clears all conditions in query.
getId
Gets query ID.
setId
Sets query ID.
Parameters:
id
Type:String
New Query ID
getName
Gets query name.
setName
Sets query name.
Parameters:
name
Type:String
Query name
getColumns
Get array of columns.
addColumn
Adds new column with specified index.
Parameters:
column
Type:Object
The plain JavaScript object that defines a new column.
Code examples:

{
  "caption" : "Company name",
  "sorting" : "None",
  "sortIndex" : -1,
  "expr" : {
      "typeName" : "ENTATTR",
      "id" : "Customers.Company"
  }
}

index
Type:Number
The index of new column
moveColumn
Moves the column with specified index to another position.
Parameters:
index1
Type:Number
The index of the column that should be moved.
index2
Type:Number
The index of the position the column should be moved to
removeColumn
Removes the column.
Parameters:
column
Type:Object
The column to be removed.
addChangedCallback
Adds a handler for “query changed” event.
Parameters:
callback
Type:Function
The function that will be called when query is changed. This function can take one parameter - the object which contains information what change exactly occurred.
changeType
Type:String
Contains the reason of change. The value consists of two parts separated by dot. First part can be “condition” or “column” and tells where exactly the modification occurred. Second part tells more about the type of that modification: “add”, “delete”, “move”, etc. For example: “condition.add” means that a new condition was added into the query
condition
Type:Object
Represents condition which was added or modified Can be undefined (if the query change was made in columns)
column
Type:Object
Represents condition which was added or modified Can be undefined (if the query change was made in conditions)
removeChangedCallback
Removes a handler for “query changed” event.
Parameters:
callback
Type:Function
A callback function that should be removed from the list of handlers.