EqContext class
Encapsulates all information about EasyQuery components on some webpage. Each context includes the following main components:
- one data model,
- one query,
- one result set
- one broker
- several UI widgets.
- clientListRequestHandler
- dataModel
- defaultModelId
- defaultQueryId
- initialQuery
- loadModelOnStart
- loadQueryOnStart
- onError
- onInit
- onInitialModelLoad
- onLoadModel
- onLoadQuery
- onProcessEnd
- onProcessStart
- paging
- query
- resultContent
- resultSet
- resultStatement
- useBootstrap
- addLocale
- addQueryChangedCallback
- addWidget
- clearQuery
- clearResult
- endProcess
- getBroker
- getListRequestHandler
- getModel
- getQuery
- init
- loadDefaultModel
- refreshWidgets
- removeQueryChangedCallback
- resetListCache
- setDefaultModelId
- setExternalListCache
- setModel
- startProcess
- throwError
Constructors
Section titled “Constructors”constructor
Section titled “constructor”⊕ new EqContext(): EqContext
Public Properties
Section titled “Public Properties”clientListRequestHandler
Section titled “clientListRequestHandler”● clientListRequestHandler: (data: any
, callback: (list: any
) => void
) => boolean
dataModel
Section titled “dataModel”● dataModel: DataModel
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
onError
Section titled “onError”● onError?: (message: ErrorMessage) => void
onInit
Section titled “onInit”● onInit?: () => void
onInitialModelLoad
Section titled “onInitialModelLoad”● onInitialModelLoad?: (model: DataModel) => void
onLoadModel
Section titled “onLoadModel”● onLoadModel?: (model: DataModel) => void
onLoadQuery
Section titled “onLoadQuery”● onLoadQuery?: (query: Query) => void
onProcessEnd
Section titled “onProcessEnd”● onProcessEnd?: (message: Message) => void
onProcessStart
Section titled “onProcessStart”● onProcessStart?: (message: Message) => void
paging
Section titled “paging”● paging: EqPagingOptions
● query: Query
resultContent
Section titled “resultContent”● resultContent?: string
resultSet
Section titled “resultSet”● resultSet?: EqDataTable
resultStatement
Section titled “resultStatement”● resultStatement?: string
useBootstrap
Section titled “useBootstrap”● useBootstrap: boolean
= false
Public Methods
Section titled “Public Methods”addLocale
Section titled “addLocale”Adds the translations of the EasyQuery messages for some locale
▸ addLocale(locale: string
,localeTexts: any
): void
Parameters:
Section titled “Parameters:”- locale:
string
- the ISO code of the locale (likeen
oruk
) - localeTexts:
any
- The translations of EasyQuery texts and messages. We expected an object with the struture of TextResources class 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
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
endProcess
Section titled “endProcess”Notifies all context components about the finishing of some long process
▸ endProcess(message: Message,groups?: WidgetGroup): void
Parameters:
Section titled “Parameters:”- message: Message
- groups: WidgetGroup, Optional -
Returns void
getBroker
Section titled “getBroker”Gets the current broker component
▸ getBroker(): EqBroker
Returns EqBroker
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
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
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
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
setDefaultModelId
Section titled “setDefaultModelId”Sets the ID of the default model
▸ setDefaultModelId(modelId: string
): void
Parameters:
Section titled “Parameters:”- modelId:
string
-
Returns void
setExternalListCache
Section titled “setExternalListCache”Sets the external “list cache” provider - an object which implements ExpternalListCache
inteface
▸ setExternalListCache(cache: ExternalListCache): void
Parameters:
Section titled “Parameters:”- cache: ExternalListCache -
Returns void
setModel
Section titled “setModel”Sets the content of the current data model
▸ setModel(dataModel: DataModelData): void
Parameters:
Section titled “Parameters:”- dataModel: DataModelData
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: Message,groups?: WidgetGroup): void
Parameters:
Section titled “Parameters:”- message: Message
- groups: WidgetGroup, Optional -
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(error: ErrorMessage): void
Parameters:
Section titled “Parameters:”- error: ErrorMessage -
Returns void