Pre-processing data, loaded from an external data source

Is it possible to validate data, received from an external data source, priort to sending this data to control?

I’d like to catch all “Load()” requests in web-app, and validate returned data.
In case of request processing errors, return from web-server error messages and display these messages on a web-client side.

a) you can use code like next

It will catch any server side error ( response with error status code )

webix.attachEvent("onAjaxError", function(xhr){
       alert("Error "+xhr.responseText);
})

b) you can extend the default data loading logic

var base = webix.DataDriver.xml.toObject();
webix.DataDriver.xml.toObject = function(text, response){
 //any custom logic
 return base.call(this, text, response);
}

above code allows to add a custom logic that will be triggered before parsing any incoming data.

Option (B) is great, exactly the solution I’m looking for, but I could not make it working.

Included (B) in head section of the page. http://webix.com/snippet/fea47bf9

Issues so far:

  1. The code triggers when Data is loaded, but does not recognize Configuration load events.

  2. Line 8, “return base.call(this, text, response);”, generates an error instead of passing through the xml data.

(1)

DataDriver code will be called for any DATA loading call. It means if you are using it with load command of any component - it will be triggered. As for configuration it will work if you are using webix.markup.parse with XML string, it will not work if you are using parse with XML object ( as there will not be a toObject call in that case )

If you mean some other scenario - please share details.

(2)

Yep, sorry it was my typo, in first line it must be just a function name .toObject; , not function call .toObject()

http://webix.com/snippet/ab024e6c

Thank you for the fix.

Yes, I use webix.markup.parse and trigger works.