Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Vibhav Agrawal on Jan 07, 2010 08:08
open dhtmlx forum
Error handling in all components loading

Hi,

I am facing following issues:
1. I am trying to load the varous dhtmlx components (grid, tree, toolbar etc) using the loadXML API call provided.
But incase the xml file sent by server is invalid OR i want to show any custom error message to the user, is there any way to get the handler in my custom code so that i can process it and show a proper error message instead of "Error type: LoadXML, Description: Incorrect XML".
2. Also is there any way to attach some exception handling code for any component so that any API failure on that object should call the custom error handling provided by us.
3. There are some text in Layout (Collapse/Exapnd) which are hardcoded with english String. Is there any way to localize these strings so that they can be shown in the user specific locale.

Thanks,
Vibhav Agrawal
Answer posted by Alex (support) on Jan 11, 2010 06:55

Hello,

>> i want to show any custom error message to the user

You can try to use the following method:

function my_error_handler(type, name, data){
  alert("My error handler \n"+name+"\n Status:"+data[0].status);
}
dhtmlxError.catchError("LoadXML",my_error_handler);

>> Also is there any way to attach some exception handling code for any component

There is not built-in feature for that.

>> There are some text in Layout (Collapse/Exapnd) which are hardcoded with english String

Unfortunately, layout doesn't provide public method to localize the tooltips. We'll add them in one of the next builds.  In current version it's necessary to modify the dhtmlxlayout.js file. Please let us know if you need details.



Answer posted by Vibhav Agrawal on Jan 12, 2010 03:22

Hi,

Thanks for the reply.

1a. Could you please provide me the link of the documentation related to dhtmlxError component where i can get the full details of this class like modes of error (like LoadXML, ALL etc), some example of error handling to find what the three parameters (type, desc, erData) are?

1b. On same page i have initialized multiple components. So, will just one call be sufficient for error handling of all the components? If so, is there any way to get handler for each component in separate methods? like, for grid i want to write gridLoadErrorHandler(), for Tree i want to have treeLoadErrorHandler() etc.

3. Please let me know the way by which i can localize these tooltips for the hardcoded texts.

Thanks,

Vibhav Agrawal

Answer posted by Alex (support) on Jan 12, 2010 06:56

Hello

the details to dhtmlxError are http://dhtmlx.com/dhxdocs/doku.php?id=dhtmlxtree:error_handling

The second element of the third parameter is object where an error occured:

function my_error_handler(type, name, data){

    /*some code here*/

    var obj = data[1]; /*an object of a component*/

}
dhtmlxError.catchError("LoadXML",my_error_handler);

Answer posted by Alex (support) on Jan 12, 2010 07:02

>> Please let me know the way by which i can localize these tooltips for the hardcoded texts.

You can create some locale array for layout. For example:

layout.loc = {"en":{"collapse":"Collapse", "expand":"Expand"}, "ru":{"collapse":"Ñâåðíóòü", "expand":"Ðàçâåðíóòü"}};

Where layout is layout object

in the dhtmlxlayout.js you can locate the following lines:

this.polyObj[obj._idd].childNodes[0].childNodes[0].childNodes[4].title = "Expand";

this.polyObj[obj._idd].childNodes[0].childNodes[0].childNodes[4].title = "Collapse";

and replace them with 

this.polyObj[obj._idd].childNodes[0].childNodes[0].childNodes[4].title =  this.loc[this.loc_a]["expand"];

this.polyObj[anyExp].childNodes[0].childNodes[0].childNodes[4].title = this.loc[this.loc_a]["collapse"];

The property loc_a defines the locale:

layout.loc_a = "en";