EqContext class
Encapsulates all information about EasyQuery components on some webpage and provides some basic operation over those components Each context includes the following main components:
- one data model,
- one query,
- one result set
- several UI widgets.
- calcTotals
- clientListRequestHandler
- dataLoader
- defaultModelId
- defaultQueryId
- initialQuery
- loadModelOnStart
- loadQueryOnStart
- resultContent
- resultStatement
- resultTable
- useBootstrap
- addDefaultExporters
- addEventListener
- addLocale
- addQueryChangedCallback
- addWidget
- callWhenModelLoaded
- clearQuery
- clearResult
- createQuery
- endProcess
- exportResult
- fetchData
- fetchDataChunk
- fetchDrillDownData
- fireEvent
- getAllWidgetsByType
- getBaseEndpoint
- getDefaultTotalsSettings
- getExportFormats
- getExporter
- getListRequestHandler
- getModel
- getQuery
- getQueryFile
- getServices
- getTotalsSettings
- getWidgetByType
- init
- loadDefaultModel
- loadModel
- loadModelFromData
- loadQuery
- loadQueryList
- loadValueList
- newQuery
- refreshWidgets
- registerExporter
- registerServerExporter
- removeEventListener
- removeQuery
- removeQueryChangedCallback
- resetListCache
- resolveEndpoint
- saveQuery
- setDefaultModelId
- setEndpoint
- setEnpointIfNotExist
- setExternalListCache
- setTotalsSettings
- startProcess
- syncQuery
- throwError
- uploadQueryFile
- useEndpoint
- wereTotalsColumnsChanged
Constructors
Section titled “Constructors”constructor
Section titled “constructor”⊕ new EqContext(): EqContext
Public Properties
Section titled “Public Properties”calcTotals
Section titled “calcTotals”● calcTotals: boolean
= false
clientListRequestHandler
Section titled “clientListRequestHandler”● clientListRequestHandler: (data: any
, callback: (list: any
) => void
) => boolean
dataLoader
Section titled “dataLoader”● dataLoader: EasyQueryDataLoader
defaultModelId
Section titled “defaultModelId”● defaultModelId?: string
defaultQueryId
Section titled “defaultQueryId”● defaultQueryId?: string
initialQuery
Section titled “initialQuery”● initialQuery?: QueryData
loadModelOnStart
Section titled “loadModelOnStart”● loadModelOnStart: boolean
= true
loadQueryOnStart
Section titled “loadQueryOnStart”● loadQueryOnStart: boolean
= false
resultContent
Section titled “resultContent”● resultContent?: string
resultStatement
Section titled “resultStatement”● resultStatement?: string
resultTable
Section titled “resultTable”● resultTable: EasyDataTable
useBootstrap
Section titled “useBootstrap”● useBootstrap: boolean
= false
Public Methods
Section titled “Public Methods”addDefaultExporters
Section titled “addDefaultExporters”▸ addDefaultExporters(): void
Returns void
addEventListener
Section titled “addEventListener”Adds event listener for event type.
▸ addEventListener(eventType: "ready"
| "loadModel"
| "initialModelLoad"
| "loadQuery"
| "syncQuery"
| "fetchData"
| "exportResult"
,handler: (context: EqContext) => void
): string
Parameters:
Section titled “Parameters:”- eventType:
"ready"
|"loadModel"
|"initialModelLoad"
|"loadQuery"
|"syncQuery"
|"fetchData"
|"exportResult"
- The event type - handler: (context: EqContext) =>
void
- The handler for event
Returns string
▸ addEventListener(eventType: "processStart"
| "processEnd"
,handler: (context: EqContext, status: ActionStatus) => void
): string
Parameters:
Section titled “Parameters:”- eventType:
"processStart"
|"processEnd"
- handler: (context: EqContext, status: ActionStatus) =>
void
Returns string
▸ addEventListener(eventType: "error"
,handler: (context: EqContext, status: ActionStatus) => void
): string
Parameters:
Section titled “Parameters:”- eventType:
"error"
- handler: (context: EqContext, status: ActionStatus) =>
void
Returns string
addLocale
Section titled “addLocale”Adds the translations of the EasyQuery messages for some locale
▸ addLocale(locale: string
,localeInfo: LocaleInfo
): void
Parameters:
Section titled “Parameters:”- locale:
string
- the ISO code of the locale (likeen
oruk
) - localeInfo:
LocaleInfo
- Locale settings and translations of EasyQuery texts and messages. We expected an object with the struture of LocaleInfo interface here.
Returns void
addQueryChangedCallback
Section titled “addQueryChangedCallback”Register a new handler for ‘query changed’ event
▸ addQueryChangedCallback(callback: any
): void
Parameters:
Section titled “Parameters:”- callback:
any
-
Returns void
addWidget
Section titled “addWidget”Add a new widget to the context. After that the widget will start to receive messages from other context components.
▸ addWidget(widget: Widget): void
Parameters:
Section titled “Parameters:”- widget: Widget -
Returns void
callWhenModelLoaded
Section titled “callWhenModelLoaded”▸ callWhenModelLoaded(callFunc: any
): void
Parameters:
Section titled “Parameters:”- callFunc:
any
Returns void
clearQuery
Section titled “clearQuery”Clears the content of the current query
▸ clearQuery(): void
Returns void
clearResult
Section titled “clearResult”Clears all query results (the data set and the statement, if any)
▸ clearResult(): void
Returns void
createQuery
Section titled “createQuery”Creates a new query object using the current instance of EqServices
▸ createQuery(): Query
Returns Query
endProcess
Section titled “endProcess”Notifies all context components about the finishing of some long process
▸ endProcess(action: ActionStatus,groups?: WidgetGroup): void
Parameters:
Section titled “Parameters:”- action: ActionStatus
- groups: WidgetGroup, Optional -
Returns void
exportResult
Section titled “exportResult”Fetches the data for defined by this context and exports them to the specified format.
▸ exportResult(options?: ContextExportResultOptions): void
Parameters:
Section titled “Parameters:”- options: ContextExportResultOptions, Optional -
The content of the
options
parameter depends onEqExporter
implementation. Usually it containsformat
property which defines the format of the exported data (e.g.csv
), andsuccess
anderror
callbacks
Returns void
Example:
Section titled “Example:”context.exportResult({ format: csv});
fetchData
Section titled “fetchData”Fetches the data (usuall by executing current query) and processes the result.
▸ fetchData(options?: ContextFetchDataOptions): void
Parameters:
Section titled “Parameters:”- options: ContextFetchDataOptions, Optional -
The
options
parameter in addition to the options defined in ExecuteQueryOptions structure may also containsuccess
anderror
callbacks.
Returns void
Example:
Section titled “Example:”context.fetchData({ success: function(result) { //do whatever you want with the result}})
fetchDataChunk
Section titled “fetchDataChunk”▸ fetchDataChunk(options?: ContextFetchDataOptions): void
Parameters:
Section titled “Parameters:”- options: ContextFetchDataOptions, Optional
Returns void
fetchDrillDownData
Section titled “fetchDrillDownData”Fetches the data for a drill-down query (if defined) and processes the result.
▸ fetchDrillDownData(options: ContextFetchDataOptions): void
Parameters:
Section titled “Parameters:”- options: ContextFetchDataOptions -
Returns void
fireEvent
Section titled “fireEvent”Fires event.
▸ fireEvent(eventType: "ready"
| "loadModel"
| "initialModelLoad"
| "loadQuery"
| "syncQuery"
| "fetchData"
| "exportResult"
): any
Parameters:
Section titled “Parameters:”- eventType:
"ready"
|"loadModel"
|"initialModelLoad"
|"loadQuery"
|"syncQuery"
|"fetchData"
|"exportResult"
- The event type.
Returns any
▸ fireEvent(eventType: "processStart"
| "processEnd"
,data: ActionStatus): any
Parameters:
Section titled “Parameters:”- eventType:
"processStart"
|"processEnd"
- data: ActionStatus
Returns any
▸ fireEvent(eventType: "error"
,data: Error
): any
Parameters:
Section titled “Parameters:”- eventType:
"error"
- data:
Error
Returns any
getAllWidgetsByType
Section titled “getAllWidgetsByType”Returns all widgets with current type.
▸ getAllWidgetsByType(widgetType: string
): Widget[]
Parameters:
Section titled “Parameters:”- widgetType:
string
- The widget type
Returns Widget[]
getBaseEndpoint
Section titled “getBaseEndpoint”▸ getBaseEndpoint(): string
Returns string
getDefaultTotalsSettings
Section titled “getDefaultTotalsSettings”▸ getDefaultTotalsSettings(): TotalsOptions
Returns TotalsOptions
getExportFormats
Section titled “getExportFormats”▸ getExportFormats(): string
[]
Returns string
[]
getExporter
Section titled “getExporter”▸ getExporter(format: string
): EqExporter | null
Parameters:
Section titled “Parameters:”- format:
string
Returns EqExporter | null
getListRequestHandler
Section titled “getListRequestHandler”Gets the handler for ‘GetList’ requests
▸ getListRequestHandler(): any
Returns any
getModel
Section titled “getModel”Gets the current data model
▸ getModel(): DataModel
Returns DataModel
getQuery
Section titled “getQuery”Gets the current query
▸ getQuery(): Query
Returns Query
getQueryFile
Section titled “getQueryFile”▸ getQueryFile(options?: ContextGetQueryFileOptions): void
Parameters:
Section titled “Parameters:”- options: ContextGetQueryFileOptions, Optional
Returns void
getServices
Section titled “getServices”▸ getServices(): EqServiceProvider
Returns EqServiceProvider
getTotalsSettings
Section titled “getTotalsSettings”▸ getTotalsSettings(): TotalsOptions
Returns TotalsOptions
getWidgetByType
Section titled “getWidgetByType”Returns first registerd widget with current type
▸ getWidgetByType(widgetType: string
): Widget | null
Parameters:
Section titled “Parameters:”- widgetType:
string
- The widget type
Returns Widget | null
Initializes the context
▸ init(options?: EqContextOptions): void
Parameters:
Section titled “Parameters:”- options: EqContextOptions, Optional -
Returns void
loadDefaultModel
Section titled “loadDefaultModel”If defaultModelId
property is define - this method calls loadModel
function in the broker
to load the model with such ID.
▸ loadDefaultModel(): void
Returns void
loadModel
Section titled “loadModel”Starts the process of the model loading.
This method can initiate a request to EasyQueryServer backend or get the model from OData or GraphQL endpoint
The content of the options
parameter depends on concrete loader implementation.
▸ loadModel(options?: ContextLoadModelOptions): Promise
<DataModel>
Parameters:
Section titled “Parameters:”- options: ContextLoadModelOptions, Optional - A map of options to pass to
loadModel
function (can be ommited)
Returns Promise
<DataModel>
Example:
Section titled “Example:”context.loadModel() .then(model => { alert("Model loaded!"); });
loadModelFromData
Section titled “loadModelFromData”Sets the content of the current data model
▸ loadModelFromData(modelPlainData: ModelPlainData): void
Parameters:
Section titled “Parameters:”- modelPlainData: ModelPlainData
Returns void
loadQuery
Section titled “loadQuery”Loads the query
▸ loadQuery(options?: ContextLoadQueryOptions): void
Parameters:
Section titled “Parameters:”- options: ContextLoadQueryOptions, Optional -
The content of the
options
parameter depends onQueryStorage
implementation. Usually it containssuccess
,error
callbacks andqueryId
property of the query to load.
Returns void
Example:
Section titled “Example:”context.loadQuery({ queryId: "query-id"});
loadQueryList
Section titled “loadQueryList”Loads the list of queries available for the current user.
▸ loadQueryList(options?: ContextLoadQueryListOptions): void
Parameters:
Section titled “Parameters:”- options: ContextLoadQueryListOptions, Optional -
The content of the
options
parameter depends onQueryStorage
implementation. Usually it containssuccess
,error
callbacks
Returns void
loadValueList
Section titled “loadValueList”Sends a loadValueList
requesthe server and processes the response.
▸ loadValueList(options?: ContextLoadValueListOptions): void
Parameters:
Section titled “Parameters:”- options: ContextLoadValueListOptions, Optional - A map of options to pass to
loadValueList
function.
Returns void
newQuery
Section titled “newQuery”Creates a new query and returns its content back to the client-side.
▸ newQuery(options?: ContextNewQueryOptions): Query
Parameters:
Section titled “Parameters:”- options: ContextNewQueryOptions, Optional -
The content of the
options
parameter depends onQueryStorage
implementation. Usually it containssuccess
,error
callbacks andsilent
option
Returns Query
Example:
Section titled “Example:”context.newQuery({ silent: true});
refreshWidgets
Section titled “refreshWidgets”This method is called automatically when some change was made either in context’s data model or query
▸ refreshWidgets(groups?: WidgetGroup): void
Parameters:
Section titled “Parameters:”- groups: WidgetGroup, Default value =
WidgetGroup.All
-
Returns void
registerExporter
Section titled “registerExporter”▸ registerExporter(format: string
,resolver: EqExporterResolver
): void
Parameters:
Section titled “Parameters:”- format:
string
- resolver:
EqExporterResolver
Returns void
registerServerExporter
Section titled “registerServerExporter”▸ registerServerExporter(format: string
,responseType: XMLHttpRequestResponseType
): void
Parameters:
Section titled “Parameters:”- format:
string
- responseType:
XMLHttpRequestResponseType
Returns void
removeEventListener
Section titled “removeEventListener”Remove event handler for event type .
▸ removeEventListener(eventType: string
,handlerId: string
): void
Parameters:
Section titled “Parameters:”- eventType:
string
- The event type. - handlerId:
string
- The handler id.
Returns void
removeQuery
Section titled “removeQuery”Removes the current query from some storage on the server-side.
▸ removeQuery(options?: ContextRemoveQueryOptions): void
Parameters:
Section titled “Parameters:”- options: ContextRemoveQueryOptions, Optional -
The content of the
options
parameter depends onQueryStorage
implementation. Usually it containssuccess
anderror
callbacks
Returns void
removeQueryChangedCallback
Section titled “removeQueryChangedCallback”Removes the function from the list of registerd handlers for ‘query changed’ event
▸ removeQueryChangedCallback(callback: any
): void
Parameters:
Section titled “Parameters:”- callback:
any
-
Returns void
resetListCache
Section titled “resetListCache”Clears the current list cache.
▸ resetListCache(): void
Returns void
resolveEndpoint
Section titled “resolveEndpoint”▸ resolveEndpoint(endpointKey: EqEndpointKey
,options?: any
): string
Parameters:
Section titled “Parameters:”- endpointKey:
EqEndpointKey
- options:
any
, Optional
Returns string
saveQuery
Section titled “saveQuery”Saves the current query to some storage on the server-side.
▸ saveQuery(options?: ContextSaveQueryOptions): void
Parameters:
Section titled “Parameters:”- options: ContextSaveQueryOptions, Optional -
The content of the
options
parameter depends onQueryStorage
implementation. Usually it containssuccess
anderror
callbacks
Returns void
setDefaultModelId
Section titled “setDefaultModelId”Sets the ID of the default model
▸ setDefaultModelId(modelId: string
): void
Parameters:
Section titled “Parameters:”- modelId:
string
-
Returns void
setEndpoint
Section titled “setEndpoint”▸ setEndpoint(key: EqEndpointKey
,value: string
): void
Parameters:
Section titled “Parameters:”- key:
EqEndpointKey
- value:
string
Returns void
setEnpointIfNotExist
Section titled “setEnpointIfNotExist”▸ setEnpointIfNotExist(key: EqEndpointKey
,value: string
): void
Parameters:
Section titled “Parameters:”- key:
EqEndpointKey
- value:
string
Returns void
setExternalListCache
Section titled “setExternalListCache”Sets the external ‘list cache’ provider - an object which implements ExternalListCache
inteface
▸ setExternalListCache(cache: ExternalListCache): void
Parameters:
Section titled “Parameters:”- cache: ExternalListCache -
Returns void
setTotalsSettings
Section titled “setTotalsSettings”▸ setTotalsSettings(settings: TotalsOptions
,silent?: boolean
): void
Parameters:
Section titled “Parameters:”- settings:
TotalsOptions
- silent:
boolean
, Default value =false
Returns void
startProcess
Section titled “startProcess”Notifies context components about starting of some long process (e.g. model loading) This method raises onProcessStart event in the context and all its widgets
▸ startProcess(message: ActionStatus,groups?: WidgetGroup): void
Parameters:
Section titled “Parameters:”- message: ActionStatus
- groups: WidgetGroup, Optional -
Returns void
syncQuery
Section titled “syncQuery”Syncronizes the current query.
▸ syncQuery(options?: ContextSyncQueryOptions): void
Parameters:
Section titled “Parameters:”- options: ContextSyncQueryOptions, Optional -
The content of the
options
parameter depends onQuerySyncronizer
implementation. Usually it containssuccess
anderror
callbacks
Returns void
throwError
Section titled “throwError”Throws the error passed in the function parameter. If onError event handler is defined - we call that method. Otherwise - just place the error message to the browser console.
▸ throwError(action: ActionStatus): void
Parameters:
Section titled “Parameters:”- action: ActionStatus
Returns void
uploadQueryFile
Section titled “uploadQueryFile”▸ uploadQueryFile(options?: ContextUploadQueryFileOptions): void
Parameters:
Section titled “Parameters:”- options: ContextUploadQueryFileOptions, Optional
Returns void
useEndpoint
Section titled “useEndpoint”Sets endpoint for all EasyQuery actions. Should be called before init
and
useEnterprise
methods
▸ useEndpoint(endpoint: string
): EqContext
Parameters:
Section titled “Parameters:”- endpoint:
string
Returns EqContext
Example:
Section titled “Example:”
view.getContext() .useEndpoint(‘/api/easyquery’) .useEnterprise(function () { view.init(); });
wereTotalsColumnsChanged
Section titled “wereTotalsColumnsChanged”▸ wereTotalsColumnsChanged(settings?: TotalsOptions
): boolean
Parameters:
Section titled “Parameters:”- settings:
TotalsOptions
, Optional
Returns boolean
Protected Methods
Section titled “Protected Methods”startQueryListLoading
Section titled “startQueryListLoading”▸ startQueryListLoading(options?: ContextLoadQueryListOptions): void
Parameters:
Section titled “Parameters:”- options: ContextLoadQueryListOptions, Optional
Returns void