File

src/core/smart-data-source/smart-datasource.ts

Extends

AbstractSmartDataSource

Implements

ICRUDHookable

Index

Properties
Methods
Accessors

Constructor

constructor(config: SmartDataSourceConfig)

Creates an instance of SmartDataSource.

Parameters :
Name Type Optional
config SmartDataSourceConfig No

Properties

Public afterSaveChanges
Type : AfterEventCallback

A callback to be executed after saving changes.

Public autoFetch
Type : boolean

If set to false, prevents the Smart Data Source from auto fetching records when the filter or runtimeFilters have changed or when a selection changed event has been fired by a parent Smart Data Source,

Public beforeDelete
Type : BeforeEventCallback
Public beforeSaveChanges
Type : BeforeEventCallback

A callback to be executed before saving changes.

clientSideCount
Type : unknown
Default value : false
Public dataRequested
Type : DataRequestedCallback
Public foreignFieldMap
Type : any
Public initialDataFetched
Type : boolean
Public jsdo
Type : progress.data.JSDO
Public onInitialDataFetched
Type : EventEmitter<boolean>
Default value : new EventEmitter<boolean>()
Public partialDataset
Type : boolean

Indicates whether the data source currently uses partial dataset handling.

This value is derived from the JSDO table reference root-table metadata. Caller-provided partialDataset configuration values are ignored.

Public serverSideFiltering
Type : boolean
Public serverSideSorting
Type : unknown
Default value : true
Public state
Type : StateEvents
Default value : StateEvents.IDLE
Public stateChanged
Type : EventEmitter<DataSourceStateChangeEventArgs>
Default value : new EventEmitter<DataSourceStateChangeEventArgs>()

Fired when the datasource's state changes.

Public useSubmitMode
Type : unknown
Default value : false

When true, save operations are sent to the backend in JSDO submit mode (the whole change-set as a single operation) instead of per-record CUD mode. Enable this for entities whose backend creates MULTIPLE rows from one submitted record (e.g. CSV / multi-value expansion): non-submit CUD rejects a multi-row response with jsdoMSG100 ("too many records"). Submit mode accepts it, but does not merge the extra server-created rows into local storage, so re-read the data source after save (e.g. refreshCurrentBatch()) to display them. Defaults to false, preserving per-record CUD behavior for every other data source.

Public afterDelete
Type : AfterEventCallback

Callback function to be executed after deleting.

Abstract autoSelectFirstRecord
Type : boolean
Public Optional batchSize
Type : number

The batch size for fetching data.

Public Readonly config
Type : AbstractSmartDataSourceConfig
Public getInitialValues
Type : boolean
instanceName
Type : string
Public name
Use instanceName instead
Type : string

The unique name by which the data source will be identified.

objectName
Use instanceName instead
Type : string
Readonly queryResultSignal
Type : WritableSignal<QueryResult<unknown>>
Default value : signal({ data: [], total: 0 })
Readonly recordCancelled
Type : EventEmitter<boolean>
Default value : new EventEmitter<boolean>()

Emits an event when a record is cancelled The boolean indicates whether the record was being added or copied

Readonly selectedIndexSignal
Type : WritableSignal<number>
Default value : signal(-1)

Signal for reactive selected index tracking. Automatically updated when selectionChanged emits.

Readonly selectedSignal
Type : WritableSignal<unknown | null>
Default value : signal(null)

Signal for reactive selected record tracking. Automatically updated when selectionChanged emits.

selectionChanged
Type : EventEmitter<SelectionChangedEventArgs<unknown>>
Default value : new EventEmitter()
Public Abstract Optional skipRecords
Type : number
Readonly stateSignal
Type : WritableSignal<StateEvents>
Default value : signal( StateEvents.IDLE )

Signal for reactive state tracking. Automatically updated when stateChanged emits.

Public Abstract Optional top
Type : number

Methods

Public Async addRecord
addRecord(initialRecord?: unknown, atIndex: number)

Adds a new record and puts the datasource in ADD_RECORD state.

Parameters :
Name Type Optional Default value Description
initialRecord unknown Yes
  • The initial record to add.
atIndex number No 0
  • The index to insert the record at.
Returns : Promise<boolean>
  • A promise that resolves to true if the record was added successfully.
Public cancelAll
cancelAll()
Returns : void
Public cancelCurrentRequest
cancelCurrentRequest()

Cancels the current GET request, if one is ongoing

Returns : void
Public cancelRecord
cancelRecord(emitSelectionChanged: unknown)

Cancels all changes made to the currently selected record.

Parameters :
Name Type Optional Default value Description
emitSelectionChanged unknown No false
  • whether to emit a selection changed event
Returns : void
Public clear
clear()

Clears all data loaded on the client side and closes the data source's query

Returns : void
Public copyRecord
copyRecord(atIndex: number)

Copies the currently selected record and selects the copy

Parameters :
Name Type Optional Default value Description
atIndex number No 0
  • The index to insert the copy at.
Returns : Promise<boolean>
Public Async deleteRecord
deleteRecord()

Deletes the currently selected record.

Returns : Promise<void>
Public Async fetch
fetch(query?: IQuery)

Performs a read request and loads data.

Parameters :
Name Type Optional
query IQuery Yes
Public getABLQueryString
getABLQueryString()

Returns the ABL query string that aggregates getFilterBasedOnParent() and compoundedQueryString.

Returns : string
Public getChildDataSource
getChildDataSource(viewTable: string)
Parameters :
Name Type Optional
viewTable string No

{SmartChildDataSource}

Public getEmptyRecord
getEmptyRecord()

Creates an empty record that adheres to the datasource's table schema.

Returns : any
Public getJSDOSchemaForTable
getJSDOSchemaForTable(tableName: string)
Parameters :
Name Type Optional
tableName string No

JSDOFieldDefinition[]

Public getRecords
getRecords(request: any)

Returns parent business entity with child records if exist

Parameters :
Name Type Optional Description
request any No
  • full request
Returns : any
Public getSmartRestrictions
getSmartRestrictions(jsdo: unknown)
Parameters :
Name Type Optional Default value
jsdo unknown No this.jsdo
Returns : SmartRestrictions

SmartRestrictions

Public Async handleError
handleError(request: any)

Handles errors that occur during CRUD operations.

Parameters :
Name Type Optional Description
request any No
  • The request that caused the error.
Returns : unknown
handleParentNavigationDisabled
handleParentNavigationDisabled(navigationDisabled: boolean)
Parameters :
Name Type Optional
navigationDisabled boolean No
Returns : void
Public invokeMethod
invokeMethod(methodName: string, request: JSDOMethodRequest, handleErrors: unknown)

Invokes a method that has been defined in the JSDO Catalog. An exception is thrown if the method is not defined in the catalog or if it is not of type "invoke".

Parameters :
Name Type Optional Default value
methodName string No
request JSDOMethodRequest No
handleErrors unknown No true
Returns : Promise<any>
Public namedQuery
namedQuery(query: NamedQuery)
Parameters :
Name Type Optional
query NamedQuery No

Promise

Public refreshCurrentBatch
refreshCurrentBatch()

Re-executes the last query.

Public Async saveChanges
saveChanges()

Save all changes made to the selected record.

Returns : Promise<void>
Public saveRecord
saveRecord()
Returns : Promise<void>
Public selectNextRecord
selectNextRecord()

Selects the next loaded record. If the current record is also the last one, the first loaded record is selected.

Returns : void
Public selectPreviousRecord
selectPreviousRecord()

Selects the previous record. If the current record is also the first one, the last loaded record is selected.

Returns : void
Public setFilter
setFilter(value: any | any[] | string)

Overrides the setFilter to not throw an error if ABL query strings and Kendo UI filters are mixed.

Parameters :
Name Type Optional Description
value any | any[] | string No
  • The filter to set.
Returns : void
Public setNavigationDisabled
setNavigationDisabled(val: boolean, sourceDsName: string)
Parameters :
Name Type Optional
val boolean No
sourceDsName string No
Returns : void
Public setRuntimeFilter
setRuntimeFilter(value: CompositeFilterDescriptor | FilterDescriptor[] | string)

Overrides the setRuntimeFilter to not throw an error if ABL query strings and Kendo UI filters are mixed.

Parameters :
Name Type Optional
value CompositeFilterDescriptor | FilterDescriptor[] | string No
Returns : void
Public clearAllFilters
clearAllFilters()

Clears all initial and runtime filters

Returns : void
Public clearFilter
clearFilter()

Clears all non-runtime filters and reapplies the last query if there is one

Returns : void
Public clearRuntimeFilter
clearRuntimeFilter()

Clears all runtime filters and reapplies the last query if there is one

Returns : void
Public fetchInitialData
fetchInitialData()

Performs the initial auto-fetch using the same query shape as the constructor-time auto-fetch path.

Public getDataSource
getDataSource()

Gets the data source

the data source

Public getSelectedRecords
getSelectedRecords()

Returns the selected records

Returns : unknown[]

the selected records

Public setActiveChild
setActiveChild(active: boolean)

Sets the active state of the child data source. If the data source is set to active, it will fetch data when the parent data source has a valid selection.

Parameters :
Name Type Optional
active boolean No
Returns : void
Public setSortWithoutRefresh
setSortWithoutRefresh(value: SortDescriptor[] | string)

Sets the sort order without refreshing the last query.

Parameters :
Name Type Optional Description
value SortDescriptor[] | string No
  • The sort order to store.
Returns : void
Public subscribe
subscribe(observerOrNext?: Partial<Observer<QueryResult<unknown>>> | unknown)
Parameters :
Name Type Optional
observerOrNext Partial<Observer<QueryResult<unknown>>> | unknown Yes
Returns : Subscription
Public unsubscribe
unsubscribe()

Unsubscribes from all subscriptions and sets the observed flag to false.

Returns : void

Accessors

stopAfter
getstopAfter()
Returns : number
setstopAfter(value: number)
Parameters :
Name Type Optional
value number No
Returns : void
totalRecords
gettotalRecords()

The total number of records reported by the count method defined in the JSDO Catalog, or the number of loaded records if it is not defined.

Returns : number
loadedRecords
getloadedRecords()

The total number of loaded records.

Returns : number
top
gettop()

The maximum number of records to read in a single fetch request.

Returns : number
skipRecords
getskipRecords()

The number of records to skip when making a fetch request.

Returns : number
hasPreviousQuery
gethasPreviousQuery()
Returns : boolean
addingRecord
getaddingRecord()

True if the datasource is currently adding a record.

Returns : boolean
compoundedQueryFilter
getcompoundedQueryFilter()

Gets the compounded query filter. If both filter and runtimeFilters are set:

  • if neither is a string, base class implementation will be used.
  • if both are strings, base class implementation will be used.
  • if one is an ABL query string, the other will be converted to ABL query string as well and combined with AND. If only one or none is set, the base class implementation will be used.
Returns : string | CompositeFilterDescriptor
updatingRecord
getupdatingRecord()

True if the datasource is currently updating a record.

Returns : boolean
setupdatingRecord(value: boolean)
Parameters :
Name Type Optional
value boolean No
Returns : void
copyingRecord
getcopyingRecord()

True if the datasource is currently copying a record.

Returns : boolean
navigationDisabled
getnavigationDisabled()
Returns : boolean
beforeImage
getbeforeImage()

The before-image of the currently selected record, including the before-image of each child/view table. The cloned _selectedCopy already carries the pristine view-table data nested at selection time; for an editable child grid that tracks its own before-state, prefer that SmartChildDataSource's before-image when it has one. Returns an immutable copy.

Returns : any
selected
getselected()

The currently selected record, if any

Returns : any
setselected(value: any)

Sets the currently selected record.

Parameters :
Name Type Optional
value any No
Returns : void
selectedIndex
getselectedIndex()

Gets the index of the currently selected record.

Returns : number
setselectedIndex(value: number)

Sets the current selected record index and updates the selection accordingly.

Parameters :
Name Type Optional
value number No
Returns : void
primaryKeys
getprimaryKeys()

The primary keys of the datasource's referenced table.

Returns : string[]
jsdoSchema
getjsdoSchema()

Gets the underlying JSDO schema

viewTables
getviewTables()

The view tables that the underlying JSDO is using

Returns : string[]
runtimeFilters
getruntimeFilters()
Returns : CompositeFilterDescriptor | [] | string
setruntimeFilters(value: CompositeFilterDescriptor | FilterDescriptor[] | string)
Parameters :
Name Type Optional
value CompositeFilterDescriptor | FilterDescriptor[] | string No
Returns : void
tables
gettables()
Returns : any
tableRef
gettableRef()
Returns : string
isReadOnly
getisReadOnly()
Returns : boolean
isReadDisabled
getisReadDisabled()
Returns : boolean
isCreateDisabled
getisCreateDisabled()
Returns : boolean
isUpdateDisabled
getisUpdateDisabled()
Returns : boolean
isDeleteDisabled
getisDeleteDisabled()
Returns : boolean
autoSelectFirstRecord
getautoSelectFirstRecord()

Indicates whether the Smart Data Source should automatically select the first record after fetching data

Returns : boolean
setautoSelectFirstRecord(value: boolean)

Indicates whether the Smart Data Source should automatically select the first record after fetching data

Parameters :
Name Type Optional
value boolean No
Returns : void

results matching ""

    No results matching ""