Table of Contents

EQ.client namespace

Contains several functions which help initilize and manage EasyQuery widgets and simplify the communications with server-side code.

Functions

init

Initializes all EasyQuery objects and widgets.
Parameters:
options
Type:Object
A map of options to pass to EasyQuery core objects and widgets. By default all parameters are taken directly from easyQuerySettings global variable
serviceUrl
Type:String
Default:EasyQuery
an URL (absolute or relative) to the back-end service or controller which implements basic
modelName
Type:String
the name of the data model which will be automatically during initialization;
columnsPanel
Type:Object
A map of different options for
Code examples:

   EQ.client.init({
       serviceUrl: "EQService.asmx",
       modelName: "nwind",
       columnsPanel: { allowAggrColumns: true, attrElementFormat: "{attr}", showColumnCaptions: false  },
       queryPanel: { listRequestHandler: onListRequest }
   });

Note: You don't need to call this function directly if eq.view.js or eq.report.js script is used since the initilization code of those scriptions calls this function automatically.

loadModel

Sends a “LoadModel” requests to the server and processes the response.
Parameters:
options
Type:Object
A map of options to pass to loadModel function.
modelName
Type:String
The name of data model to load.
success
Type:Function
The function that is called on successfull model loading. Loaded model object is passed in function's parameter.
beforeSend
Type:Function
A function that is called before LoadModel request call.
Code examples:

EQ.client.loadModel({modelName: "MyModel", success: function(modelJSON) {
    alert("Model loaded!");
});

loadQuery

Sends a “LoadQuery” request to the server and processes the response.
Parameters:
options
Type:Object
A map of options to pass to loadQuery function.
queryName
Type:String
The name of query to load.
success
Type:Function
A function that is called on successfull query load. Loaded data is passed in function parameter
beforeSend
Type:Function
A function that is called before LoadQuery request call.
error
Type:Function
A function that is called if some error occurrs during LoadQuery AJAX call. The function takes 3 parameters: response code (like 404), error message and the name of operation where the problem occurs (“LoadQuery” in this case)
Code examples:

EQ.client.loadQuery({queryName: "MyQuery", success: function(queryJSON) {
    alert("Query loaded!");
});

loadQueryList

Sends a “LoadQueryList” request to the server and processes the response. The request contains the name of current model
Parameters:
options
Type:Object
The map of options to pass to loadQuery function.
success
Type:Function
The function that is called on successfull response. Requested list of queries is passed in the function parameter
beforeSend
Type:Function
The function that is called before LoadQueryList request call.
Code examples:

EQ.client.loadQueryList({success: function(listJSON) {
    alert("Queries: " + listJSON);
});

clearQuery

Clears all conditions and columns in the current query.

saveQuery

Sends “SaveQuery” request to the server and processes the response.
Parameters:
options
Type:Object
The map of options to pass to SaveQuery function.
query
Type:Object
The object that represents query to save. If not set - the current query is used.
queryName
Type:String
The name of the query
success
Type:Function
The function that is called on successfull query saving.
beforeSend
Type:Function
The function that is called before SaveQuery request call. You can show some progress animation at this point.

buildQuery

Sends “BuildQuery” request to the server and processes the response.
Parameters:
params
Type:Object
A map of parameters to pass to buildQuery function.
query
Type:Object
An object that represents query to build.
extraParams
Type:String
A string that represents extra parameters which are added to the request
success
Type:Function
A function that is called on successfull query build. This function takes one parameter which contains genereated statement in “statement” property or the error message in “error” property if some problem occurred during query building process.
beforeSend
Type:Function
A function that is called before BuildQuery request call.

syncQuery

Sends “SyncQuery” request to the server and processes the response.
Parameters:
params
Type:Object
A map of parameters to pass to buildQuery function.
query
Type:Object
An object that represents query to build.
extraParams
Type:String
A string that represents extra parameters which are added to the request
success
Type:Function
A function that is called on successfull query build. This function takes one parameter which contains genereated statement in “statement” property or the error message in “error” property if some problem occurred during query building process.
beforeSend
Type:Function
A function that is called before BuildQuery request call.

buildAndExecute

Sends “ExecuteQuery” request to the server and processes the response.
Parameters:
params
Type:Object
A map of parameters to pass to buildQuery function.
query
Type:Object
An object that represents query to build and execute.
extraParams
Type:String
A string that represents extra parameters which are added to the request
success
Type:Function
A function that is called on successfull query build. This function takes one parameter “data” - a plain object which contains genereated statement in its “statement” property and the result of query execution in “resultSet” property.
beforeSend
Type:Function
A function that is called before BuildQuery request call.