PDA

View Full Version : Help TreePanel, TreeLoader Error Handling (.40 alpha)



Nick
5 Feb 2007, 3:28 PM
Yui-ext users,

In the case of loading tree nodes asynchronously, do you have examples of how you're handling errors?

1. I would like to have a timeout in the case where the server is taking too long to respond. However, it looks like
YAHOO.ext.tree.TreeLoader : requestData() doesn't provide a way to specify a timeout. (other than modifying code?)

2. I've attached a "loadexception" listener (which gets called just fine in the case of an error), but how do I get the node back to is original (unexpanded) state,
so that a user could try again? What I'd like to do-- is set a CSS class on the node that failed (a folder icon with a red star on it) to indicate
node has not loaded. User can click on this node to try again.

3. On the node itself, I'd like to provide a tooltip. A <span title="some text"> for the n.text , would be just fine. Is there a way to do this without modifying
the var buf = [' ... code in the render() function?
3a. I see there is some qtip (quick tip) support, but I'm not sure how to utilize it, or if this would work on dynamically loaded tree nodes.

Code or suggestions on the above-- ways to handle (server) errors in TreeLoader would be appreciated.

Thank you,
Nick

insaned
23 Feb 2007, 12:34 AM
Hi Nick,

Here is my workaround for 2)


treePanelLoader.on('loadexception', function(treePanel, node, response) {

Ext.MessageBox.alert(
document.title,
Data.Strings.ErrorLoaderException);

window.setTimeout(function() {

node.collapse(false, false);

while(node.firstChild){

node.removeChild(node.firstChild);
}

node.childrenRendered = false;
node.loaded = false;

node.ui.updateExpandIcon();

}, 250);
});

"load" is fired after "loadexception". In Jack's "load" handler there is a call to expand(...). Using window.setTimeout(...) allows you to invoke the callback after the "load" handler has finished executing.

Jack, is it possible to have "loadException" fired after the "load" event or at least a way to disable the call to expand(...) if there was a loadException? Perhaps a new event "loadFailed"? Thank you.

Hope this helps.

bluestone0324
12 Oct 2010, 6:26 PM
It work! Thanks.