I’m trying to figure out how to use Webix DataTable with legacy REST services that return its result in a non-webix way.
To fetch data and populate a DataTable using a custom server response was quite easy. The steps I used was
- Create a new DataDriver that extends the existing json DataDriver
- Implement a custom toObject(text, response) method in the new data driver
that adapts the the server result to the model Webix uses ( {pos, total_count, data[] } ) - Specify the new DataDriver in DataTable using the “datatype” property
But I’m not able to figure out what I must do to be able to handle a custom JSON response from POST, PUT and DELETE requests!
I was able to adjust the URL format & parameters used by Webix when performing REST requests against the server by
- Create a new Proxy named “customProxy” that extends webix.proxy.json
- In the new proxy override the load & save functions
- In the DataTable config use the “customProxy->” prefix in the url and save.url properties.
But the problem now is where and how shall I add the logic that adapts the custom response from the server when a POST, PUT or DELETE is submitted?
I have looked at the DataProcessor and maybe the processResult() method can be where I add the adaption. But I still want the normal internal default logic of the DataProcessor to continue after I have adapted the result! The DataProcessor seems to be created by the “save” config in the DataTable and I have found no clean / simple way to append logic to the processResult().
I could use webix.wrap() but then I must add logic somewhere that keeps track of all the UI components that has a DataProcessor and apply the “wrap” fix to all those instances.
There must be simpler way that I haven’t found yet!