Whenever Webix makes an Ajax request, I’d like the opportunity to be able to pass a message back with it and have that displayed in a dialog or webix notification. For example, when I call datatable.add() this automatically fires off an Ajax POST request to the server, the servers saves the record and returns the ID of the new row. Such as
{ id: 12 }
But I’d like to be able to extend this an include additional information, such as a notifications and errors which automatically get displayed
{ id: 12, error: Object was saved but with errors }
Can anybody recommend a method for doing this? I’m looking to do much with the returned message, just have it flash up as either a dialog or as a normal webix notification. But I’m trying to avoid having to place lots of code for checking, so would ideally be looking for a way to just override Webix’s default functionality and insert this as additional part of the operation.
Also, is there anyway of deny a remove/add operation from the server, so for example if I call datatable.remove(10), if the server runs some logic, for example this row 10 has dependencies, I can simply return “false” and it will not be removed from the Datatable? I doubt its possible, as it can could be done using the onBeforeDelete() handler, but that of course creates a lot more code and additional ajax requests.
for example this row 10 has dependencies, I can simply return "false"
Nope. The client side operations are “optimistic” so they add|update|delete data in the client side component before sending data to the server side, as result operation can’t be reverted when server side returns “false”
We are aware about issue, so next updates will include some way of undo for editable components, including the datatable. It may be included in Webix 2.2, but it is not fully decided yet.
a) Subclass the component ( datatable ) by creating your own ( savetable ) which will use the above event handler. In such case, you will be able to use in UI markup view:“savetable”, that will work the same as datatable and will contain your onUpdate handler http://docs.webix.com/desktop__custom_component.html
Thanks again Maksim, one last question, does a DataTree have an onAfterUpdate event? I’ve got the following code, but the alert is not firing (it works ok with the DataTable) -