Skip to content

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.

⊕ new EqContext(): EqContext



● clientListRequestHandler: (data: any, callback: (list: any) => void) => boolean


● defaultModelId?: string


● defaultQueryId?: string


● initialQuery?: QueryData


● loadModelOnStart: boolean = true


● loadQueryOnStart: boolean = false


● resultContent?: string


● resultSet?: EqDataTable


● resultStatement?: string


● useBootstrap: boolean = false



● antiForgeryToken: string



▸ addDefaultExporters(): void

Returns void


Adds event listener for event type.

▸ addEventListener(eventType: "ready",handler: () => void): string

  • eventType: "ready" - The event type
  • handler: () => void - The handler for event

Returns string

▸ addEventListener(eventType: "loadModel" | "initialModelLoad",handler: (model: DataModel) => void): string

  • eventType: "loadModel" | "initialModelLoad"
  • handler: (model: DataModel) => void

Returns string

▸ addEventListener(eventType: "loadQuery",handler: (query: Query) => void): string

  • eventType: "loadQuery"
  • handler: (query: Query) => void

Returns string

▸ addEventListener(eventType: "processStart" | "processEnd",handler: (message: StatusMessage) => void): string

  • eventType: "processStart" | "processEnd"
  • handler: (message: StatusMessage) => void

Returns string

▸ addEventListener(eventType: "error",handler: (error: StatusMessage) => void): string

Returns string


Adds the translations of the EasyQuery messages for some locale

▸ addLocale(locale: string,localeTexts: any): void

  • locale: string - the ISO code of the locale (like en or uk)
  • localeTexts: any - The translations of EasyQuery texts and messages. We expected an object with the struture of TextResources class here.

Returns void


Register a new handler for ‘query changed’ event

▸ addQueryChangedCallback(callback: any): void

  • callback: any -

Returns void


Add a new widget to the context. After that the widget will start to receive messages from other context components.

▸ addWidget(widget: Widget): void

Returns void


▸ callWhenModelLoaded(callFunc: any): void

  • callFunc: any

Returns void


Clears the content of the current query

▸ clearQuery(): void

Returns void


Clears all query results (the data set and the statement, if any)

▸ clearResult(): void

Returns void


Notifies all context components about the finishing of some long process

▸ endProcess(message: StatusMessage,groups?: WidgetGroup): void

Returns void


Executes the current query and processes the result.

▸ executeQuery(options?: any): void

  • options: any, Optional - The content of the options parameter depends on QueryExecutor implementation. Usually it contains page property which defines the page of the executed result (e.g. 2), success and error callbacks

Returns void

context.executeQuery({
page: 2
})

Executes the current query and exports the result to the specified format.

▸ exportResult(options?: any): void

  • options: any, Optional - The content of the options parameter depends on EqExporter implementation. Usually it contains format property which defines the format of the exported data (e.g. csv), success and error callbacks

Returns void

context.exportResult({
format: csv
});

Fires event.

▸ fireEvent(eventType: "ready"): any

  • eventType: "ready" - The event type.

Returns any

▸ fireEvent(eventType: "loadModel" | "initialModelLoad",data: DataModel): any

  • eventType: "loadModel" | "initialModelLoad"
  • data: DataModel

Returns any

▸ fireEvent(eventType: "loadQuery",data: Query): any

  • eventType: "loadQuery"
  • data: Query

Returns any

▸ fireEvent(eventType: "processStart" | "processEnd",data: StatusMessage): any

Returns any

▸ fireEvent(eventType: "error",data: Error): any

  • eventType: "error"
  • data: Error

Returns any


▸ getBaseEndpoint(): string

Returns string


Gets the current broker component. REMOVE!!!!!

▸ getBroker(): this

Returns this


▸ getExporter(format: string): EqExporter | null

  • format: string

Returns EqExporter | null


Gets the handler for ‘GetList’ requests

▸ getListRequestHandler(): any

Returns any


Gets the current data model

▸ getModel(): DataModel

Returns DataModel


Gets the current query

▸ getQuery(): Query

Returns Query


▸ getServices(): EqServiceProvider

Returns EqServiceProvider


Initializes the context

▸ init(options?: EqContextOptions): void

Returns void


If defaultModelId property is define - this method calls loadModel function in the broker to load the model with such ID.

▸ loadDefaultModel(): void

Returns void


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?: any): Promise<DataModel>

  • options: any, Optional - A map of options to pass to loadModel function (can be ommited)

Returns Promise<DataModel>

context.loadModel()
.then(model => {
alert("Model loaded!");
});

Sets the content of the current data model

▸ loadModelFromData(modelPlainData: ModelPlainData): void

Returns void


Loads the query

▸ loadQuery(options?: any): void

  • options: any, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success, error callbacks and id option of query to load.

Returns void

context.loadQuery({
id: "query-id"
});

Loads the list of queries available for the current user.

▸ loadQueryList(options?: any): void

  • options: any, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success, error callbacks

Returns void


Sends a loadValueList requesthe server and processes the response.

▸ loadValueList(options?: any): void

  • options: any, Optional - A map of options to pass to loadValueList function.

Returns void


Creates a new query and returns its content back to the client-side.

▸ newQuery(options?: any): void

  • options: any, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success, error callbacks and silent option

Returns void

context.newQuery({
silent: true
});

This method is called automatically when some change was made either in context’s data model or query

▸ refreshWidgets(groups?: WidgetGroup): void

  • groups: WidgetGroup, Default value = WidgetGroup.All -

Returns void


▸ registerExporter(format: string,resolver: EqExporterResolver): void

  • format: string
  • resolver: EqExporterResolver

Returns void


Remove event handler for event type .

▸ removeEventListener(eventType: string,handlerId: string): void

  • eventType: string - The event type.
  • handlerId: string - The handler id.

Returns void


Removes the current query from some storage on the server-side.

▸ removeQuery(options?: any): void

  • options: any, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success and error callbacks

Returns void


Removes the function from the list of registerd handlers for ‘query changed’ event

▸ removeQueryChangedCallback(callback: any): void

  • callback: any -

Returns void


Clears the current list cache.

▸ resetListCache(): void

Returns void


▸ resolveEndpoint(endpointKey: EqEndpointKey,options?: any): string

  • endpointKey: EqEndpointKey
  • options: any, Optional

Returns string


Saves the current query to some storage on the server-side.

▸ saveQuery(options?: any): void

  • options: any, Optional - The content of the options parameter depends on QueryStorage implementation. Usually it contains success and error callbacks

Returns void


Sets the ID of the default model

▸ setDefaultModelId(modelId: string): void

  • modelId: string -

Returns void


▸ setEndpoint(key: EqEndpointKey,value: string): void

  • key: EqEndpointKey
  • value: string

Returns void


▸ setEnpointIfNotExist(key: EqEndpointKey,value: string): void

  • key: EqEndpointKey
  • value: string

Returns void


Sets the external ‘list cache’ provider - an object which implements ExternalListCache inteface

▸ setExternalListCache(cache: ExternalListCache): void

Returns void


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: StatusMessage,groups?: WidgetGroup): void

Returns void


Syncronizes the current query.

▸ syncQuery(options?: any): void

  • options: any, Optional - The content of the options parameter depends on QuerySyncronizer implementation. Usually it contains success and error callbacks

Returns void


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(msg: StatusMessage): void

Returns void