Hi,
I am creating custom DataSource using local data stored in PouchDB.
To implement filtering according to AdvancedCriteria, I need to fetch all records and filter them app-side.
Here is dummy code:
This does not work however as during the call to applyFilter dsRequest.data is not initial criteria, but undefined.
It was not clear to me in transformRequest documentation, that you need to return dsRequest or dsRequest.data even for clientCustom protocol. Lack of return means implicitly returning undefined which is then saved to dsRequest.data back in datasource.sendDSRequest.
On the moment promise resolves and we continue processing, dsRequest is already modified by:
Maybe you could update documentation about that or ignore undefined result from transformRequest.
Best regards,
Janusz
I am creating custom DataSource using local data stored in PouchDB.
To implement filtering according to AdvancedCriteria, I need to fetch all records and filter them app-side.
Here is dummy code:
Code:
transformRequest: function(dsRequest) { getAllRecordsFromDBAndReturnPromise().then(allRecords => { const dsResponse = { status: isc.DSResponse.STATUS_SUCCESS, data: this.applyFilter(records, dsRequest.data || {}, dsRequest), }; this.processResponse(dsRequest.requestId, dsResponse); }); }
It was not clear to me in transformRequest documentation, that you need to return dsRequest or dsRequest.data even for clientCustom protocol. Lack of return means implicitly returning undefined which is then saved to dsRequest.data back in datasource.sendDSRequest.
On the moment promise resolves and we continue processing, dsRequest is already modified by:
Code:
var transformedData = this.transformRequest(dsRequest); // correct the common error of returning the dsRequest itself incorrectly, which is // never right since the dsRequest contains various widgets and other data // inappropriate to send to the server. if (transformedData !== dsRequest) { dsRequest.data = transformedData; }
Best regards,
Janusz
Comment