This shows you the differences between two versions of the page.
— |
easyquery:js:eq-core-ns [2015/07/27 12:32] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | |||
+ | ====== EQ.core namespace ====== | ||
+ | <jxd:nsSummary>Contains different classes and functions for managing core EasyQuery objects: data model, query, entities, attributes, operators, etc.</jxd:nsSummary> | ||
+ | |||
+ | ===== Variables ===== | ||
+ | |||
+ | |||
+ | ==== texts ==== | ||
+ | |||
+ | <jxd:var> | ||
+ | <jxd:varType>Object</jxd:varType> | ||
+ | <jxd:varDefault>{Entities: {}, Attributes: {}, Operators: {}}</jxd:varDefault> | ||
+ | <jxd:varSummary>Contains the text strings that are used in the UI divided by 3 lists. By default the internal (English) list of strings is used.</jxd:varSummary> | ||
+ | <jxd:varNotes>These lists are usually used to localize the UI.</jxd:varNotes> | ||
+ | </jxd:var> | ||
+ | |||
+ | ==== constLists ==== | ||
+ | |||
+ | <jxd:var> | ||
+ | <jxd:varType>Object</jxd:varType> | ||
+ | <jxd:varSummary>Contains the constants used to work with date/time and boolean values.</jxd:varSummary> | ||
+ | </jxd:var> | ||
+ | |||
+ | ===== Functions ===== | ||
+ | |||
+ | |||
+ | ==== getText ==== | ||
+ | |||
+ | <jxd:function> | ||
+ | <jxd:functionReturns> | ||
+ | <jxd:functionReturnsType>String</jxd:functionReturnsType> | ||
+ | <jxd:functionReturnsSummary>Text of the resource defined by key</jxd:functionReturnsSummary> | ||
+ | </jxd:functionReturns> | ||
+ | <jxd:functionSummary>Returns localized text by the key defined in parameters</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>key</jxd:paramName> | ||
+ | <jxd:paramType>String</jxd:paramType> | ||
+ | <jxd:paramSummary>The key of the resource string.</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | <jxd:functionExample> | ||
+ | Here we get the text of the resource string assigned to CmdClickToAddCondition key | ||
+ | <code> | ||
+ | var text = EQ.core.getText("CmdClickToAddCondition") | ||
+ | </code></jxd:functionExample> | ||
+ | </jxd:function> | ||
+ | |||
+ | ===== Classes ===== | ||
+ | |||
+ | ==== DataModel class ==== | ||
+ | |||
+ | <jxd:class> | ||
+ | <jxd:classSummary>Represents a data model.</jxd:classSummary> | ||
+ | |||
+ | <jxd:classMethods> | ||
+ | |||
+ | <jxd:function> | ||
+ | <jxd:functionName>getObject</jxd:functionName> | ||
+ | <jxd:functionSummary>Gets internal model object.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>setObject</jxd:functionName> | ||
+ | <jxd:functionSummary>Sets internal model object. Accepts model representation in JSON format as well.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>data</jxd:paramName> | ||
+ | <jxd:paramType>Object | String</jxd:paramType> | ||
+ | <jxd:paramSummary>Internal model representation as pure JavaScript object or as JSON string</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>isEmpty</jxd:functionName> | ||
+ | <jxd:functionSummary>Returns true if current model is empty (does not contain any entity)</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>isEmpty</jxd:functionName> | ||
+ | <jxd:functionSummary>Returns root entity object</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>getAttributById</jxd:functionName> | ||
+ | <jxd:functionReturns> | ||
+ | <jxd:functionReturnsType>Object</jxd:functionReturnsType> | ||
+ | <jxd:functionReturnsSummary>An attribute.</jxd:functionReturnsSummary> | ||
+ | </jxd:functionReturns> | ||
+ | <jxd:functionSummary>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.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>attrId</jxd:paramName> | ||
+ | <jxd:paramType>String</jxd:paramType> | ||
+ | <jxd:paramSummary>Attribute ID</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>getEntityAttrById</jxd:functionName> | ||
+ | <jxd:functionReturns> | ||
+ | <jxd:functionReturnsType>Object</jxd:functionReturnsType> | ||
+ | <jxd:functionReturnsSummary>An attribute.</jxd:functionReturnsSummary> | ||
+ | </jxd:functionReturns> | ||
+ | <jxd:functionSummary>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.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>entity</jxd:paramName> | ||
+ | <jxd:paramType>Object</jxd:paramType> | ||
+ | <jxd:paramSummary>Entity object to search in</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>attrId</jxd:paramName> | ||
+ | <jxd:paramType>String</jxd:paramType> | ||
+ | <jxd:paramSummary>Attribute ID</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>getFirstUICAttrInEntity</jxd:functionName> | ||
+ | <jxd:functionReturns> | ||
+ | <jxd:functionReturnsType>Object</jxd:functionReturnsType> | ||
+ | <jxd:functionReturnsSummary>An attribute.</jxd:functionReturnsSummary> | ||
+ | </jxd:functionReturns> | ||
+ | <jxd:functionSummary>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.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>entity</jxd:paramName> | ||
+ | <jxd:paramType>Object</jxd:paramType> | ||
+ | <jxd:paramSummary>Entity object to search our attribute in.</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>runThroughEntities</jxd:functionName> | ||
+ | <jxd:functionSummary>Scans model's entity tree and calls the callback functions for each attribute and entity.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>processAttribute</jxd:paramName> | ||
+ | <jxd:paramType>Function</jxd:paramType> | ||
+ | <jxd:paramSummary>The callback function which is called for each attribute in model's entity tree. | ||
+ | The processed attribute is passed in the first function parameter.</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>processEntity</jxd:paramName> | ||
+ | <jxd:paramType>Function</jxd:paramType> | ||
+ | <jxd:paramSummary>The callback function which is called for each entity in tree. | ||
+ | The processed entity is passed in the first function parameter.</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>findOperatorById</jxd:functionName> | ||
+ | <jxd:functionReturns> | ||
+ | <jxd:functionReturnsType>Object</jxd:functionReturnsType> | ||
+ | <jxd:functionReturnsSummary>An operator.</jxd:functionReturnsSummary> | ||
+ | </jxd:functionReturns> | ||
+ | <jxd:functionSummary>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.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>operatorId</jxd:paramName> | ||
+ | <jxd:paramType>String</jxd:paramType> | ||
+ | <jxd:paramSummary>Operator ID</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>getOperatorById</jxd:functionName> | ||
+ | <jxd:functionReturns> | ||
+ | <jxd:functionReturnsType>Object</jxd:functionReturnsType> | ||
+ | <jxd:functionReturnsSummary>An operator.</jxd:functionReturnsSummary> | ||
+ | </jxd:functionReturns> | ||
+ | <jxd:functionSummary>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.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>operatorId</jxd:paramName> | ||
+ | <jxd:paramType>String</jxd:paramType> | ||
+ | <jxd:paramSummary>Operator ID</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | </jxd:classMethods> | ||
+ | </jxd:class> | ||
+ | ==== Query class ==== | ||
+ | |||
+ | <jxd:class> | ||
+ | <jxd:classSummary>Represents internal query structure.</jxd:classSummary> | ||
+ | |||
+ | <jxd:classMethods> | ||
+ | |||
+ | <jxd:function> | ||
+ | <jxd:functionName>getObject</jxd:functionName> | ||
+ | <jxd:functionSummary>Gets internal query object.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>setObject</jxd:functionName> | ||
+ | <jxd:functionSummary>Sets internal query object. Accepts query representation in JSON format as well.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>data</jxd:paramName> | ||
+ | <jxd:paramType>Object | String</jxd:paramType> | ||
+ | <jxd:paramSummary>Internal query representation as pure JavaScript object or as JSON string</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>getModel</jxd:functionName> | ||
+ | <jxd:functionSummary>Gets DataModel object associated with this query.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>setModel</jxd:functionName> | ||
+ | <jxd:functionSummary>Sets DataModel object associated with this query.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>model</jxd:paramName> | ||
+ | <jxd:paramType>Object</jxd:paramType> | ||
+ | <jxd:paramSummary>A DataModel object</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>toJSON</jxd:functionName> | ||
+ | <jxd:functionSummary>Returns JSON representation of this query.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>isEmptyConditions</jxd:functionName> | ||
+ | <jxd:functionSummary>Returns true if query does not contain any condition.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>clear</jxd:functionName> | ||
+ | <jxd:functionSummary>Clears query (all conditions and columns).</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>clearColumns</jxd:functionName> | ||
+ | <jxd:functionSummary>Clears all columns in query.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>clearConditions</jxd:functionName> | ||
+ | <jxd:functionSummary>Clears all conditions in query.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>getId</jxd:functionName> | ||
+ | <jxd:functionSummary>Gets query ID.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>setId</jxd:functionName> | ||
+ | <jxd:functionSummary>Sets query ID.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>id</jxd:paramName> | ||
+ | <jxd:paramType>String</jxd:paramType> | ||
+ | <jxd:paramSummary>New Query ID</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>getName</jxd:functionName> | ||
+ | <jxd:functionSummary>Gets query name.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>setName</jxd:functionName> | ||
+ | <jxd:functionSummary>Sets query name.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>name</jxd:paramName> | ||
+ | <jxd:paramType>String</jxd:paramType> | ||
+ | <jxd:paramSummary>Query name</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>getColumns</jxd:functionName> | ||
+ | <jxd:functionSummary>Get array of columns.</jxd:functionSummary> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>addColumn</jxd:functionName> | ||
+ | <jxd:functionSummary>Adds new column with specified index.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>column</jxd:paramName> | ||
+ | <jxd:paramType>Object</jxd:paramType> | ||
+ | <jxd:paramSummary>The plain JavaScript object that defines a new column.</jxd:paramSummary> | ||
+ | <jxd:paramExample><code> | ||
+ | { | ||
+ | "caption" : "Company name", | ||
+ | "sorting" : "None", | ||
+ | "sortIndex" : -1, | ||
+ | "expr" : { | ||
+ | "typeName" : "ENTATTR", | ||
+ | "id" : "Customers.Company" | ||
+ | } | ||
+ | } | ||
+ | </code></jxd:paramExample> | ||
+ | </jxd:param> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>index</jxd:paramName> | ||
+ | <jxd:paramType>Number</jxd:paramType> | ||
+ | <jxd:paramSummary>The index of new column</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>moveColumn</jxd:functionName> | ||
+ | <jxd:functionSummary>Moves the column with specified index to another position.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>index1</jxd:paramName> | ||
+ | <jxd:paramType>Number</jxd:paramType> | ||
+ | <jxd:paramSummary>The index of the column that should be moved.</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>index2</jxd:paramName> | ||
+ | <jxd:paramType>Number</jxd:paramType> | ||
+ | <jxd:paramSummary>The index of the position the column should be moved to</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>removeColumn</jxd:functionName> | ||
+ | <jxd:functionSummary>Removes the column.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>column</jxd:paramName> | ||
+ | <jxd:paramType>Object</jxd:paramType> | ||
+ | <jxd:paramSummary>The column to be removed.</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>addChangedCallback</jxd:functionName> | ||
+ | <jxd:functionSummary>Adds a handler for "query changed" event.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>callback</jxd:paramName> | ||
+ | <jxd:paramType>Function</jxd:paramType> | ||
+ | <jxd:paramSummary>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.</jxd:paramSummary> | ||
+ | <jxd:props> | ||
+ | <jxd:prop> | ||
+ | <jxd:propName>changeType</jxd:propName> | ||
+ | <jxd:propType>String</jxd:propType> | ||
+ | <jxd:propSummary>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</jxd:propSummary> | ||
+ | </jxd:prop> | ||
+ | <jxd:prop> | ||
+ | <jxd:propName>condition</jxd:propName> | ||
+ | <jxd:propType>Object</jxd:propType> | ||
+ | <jxd:propSummary>Represents condition which was added or modified | ||
+ | Can be undefined (if the query change was made in columns)</jxd:propSummary> | ||
+ | </jxd:prop> | ||
+ | <jxd:prop> | ||
+ | <jxd:propName>column</jxd:propName> | ||
+ | <jxd:propType>Object</jxd:propType> | ||
+ | <jxd:propSummary>Represents condition which was added or modified | ||
+ | Can be undefined (if the query change was made in conditions)</jxd:propSummary> | ||
+ | </jxd:prop> | ||
+ | </jxd:props> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | <jxd:function> | ||
+ | <jxd:functionName>removeChangedCallback</jxd:functionName> | ||
+ | <jxd:functionSummary>Removes a handler for "query changed" event.</jxd:functionSummary> | ||
+ | <jxd:params> | ||
+ | <jxd:param> | ||
+ | <jxd:paramName>callback</jxd:paramName> | ||
+ | <jxd:paramType>Function</jxd:paramType> | ||
+ | <jxd:paramSummary>A callback function that should be removed from the list of handlers.</jxd:paramSummary> | ||
+ | </jxd:param> | ||
+ | </jxd:params> | ||
+ | </jxd:function> | ||
+ | </jxd:classMethods> | ||
+ | </jxd:class> | ||
+ | |||
+ | <PRELOAD>/apistyle.css</PRELOAD> | ||