Cancelling Smart Data Source Read Requests
The Smart Data Source provides an easy way to cancel ongoing read requests made to the backend.
This functionality is useful when the response time is high and the user decides to cancel.
Sample usage within a custom Angular Smart Form:
customerDataSource!: SmartDataSource;
constructor(injector: Injector,
private dataSourceRegistry: DataSourceRegistry) {
super(injector);
}
ngOnInit() {
// Obtain and store a reference to the data source
this.dataSourceRegistry.getDataSourceAsObservable('CustomerDataSource')
.subscribe(dataSource => this.customerDataSource = dataSource);
super.ngOnInit();
}
// This method can be bound to either from a JSON layout or a HTML template
cancel() {
this.customerDataSource.cancelCurrentRequest();
}
Note: To cancel read operations, this must be enabled at the Smart Data Source Level.
Enabling Cancelable Requests (HTML):
<smart-data-source
smart-filter-source='salesrepFilter'
smart-object-name='salesrepDataSource'
smart-business-entity-name="Consultingwerk.SmartComponentsDemo.OERA.Sports2000.SalesRepBusinessEntity"
smart-entity-table="eSalesrep"
smart-navigation-source="salesrepToolbar"
smart-read-requests-cancellable="true">
</smart-data-source>
Enabling Cancelable Requests (JSON Layout):
{
"dataSources": {
"customerDataSource": {
"objectName": "customerDataSource",
"entityName": "Consultingwerk.SmartComponentsDemo.OERA.Sports2000.CustomerBusinessEntity",
"tableRef": "eCustomer",
"entityView": "eSalesrep",
"readRequestsCancellable": true
}
}
}