View Full Version : Loading TreeLoader

20 Feb 2011, 6:08 PM
I am trying to hook up to an existing call to a web service which returns a list view of items, not a hierarchical view. I have built up the hierarchical view from a previous ajax call and would like to load this into a TreeLoader (actually the TreeGridLoader)

All of the examples cover AJAX calls - is there a way to hijack?

21 Feb 2011, 7:00 AM
A TreeLoader has a directFn config option that is called instead of the normal AJAX request.

21 Feb 2011, 7:03 AM
Excellent. There isnt any description of the directFn in the API - I thought it was something to do with ExtDirect. So I can just have it return a javascript object?

Thanks for the quick response.

21 Feb 2011, 7:07 AM
directFn is called with parameters and a callback function. The parameters depend on the paramOrder and paramsAsHash config options.

Assuming you leave paramOrder and paramsAsHash at their default value then you could use:

directFn: function(nodeId, callback) {
var nodes = [...];
callback(nodes, {status: true});

(since it's using a callback you can do your own asynchronous request in there)