PDA

View Full Version : Ext.Direct with TreePanel



gurufaction
2 Jun 2009, 1:19 PM
I've seen examples of Ext.Direct working with the DataGrid and FormPanel via the DirectStore but how does it work with the TreePanel and the TreeLoader.

p.s I'm an Ext Js n00b migrating from Flex 3 development. I already like ExtJs better :D

evant
2 Jun 2009, 6:20 PM
Wait until the upcoming RC release, I think you may be pleasantly surprised...

aconran
3 Jun 2009, 5:46 AM
Take a look at the TreeLoader example (http://extjs.com/deploy/ext-3.0-rc2/examples/direct/direct-tree.php) illustrating the use of the new directFn (http://extjs.com/deploy/ext-3.0-rc2/docs/?class=Ext.tree.TreeLoader&member=directFn) configuration.

gurufaction
3 Jun 2009, 5:52 AM
rc2 looks great and the tree example with direct is just what I needed. :D

Thanks

gurufaction
16 Jun 2009, 9:09 AM
I can't seem to get my TreeLoader to pass additional parameters to my Direct method.


region: 'west',
collapsible: true,
title: 'Navigation',
xtype: 'treepanel',
width: 200,
autoScroll: true,
split: true,
loader: new Ext.tree.TreeLoader({
directFn: Customer.getTree,
listeners: {
beforeload: function(treeLoader,node) {
this.baseParams.type = node.attributes.type;
console.log(this.baseParams);
}
}
}),
root: {id:'0',text: 'Root',type:'customer'},
listeners: {
click: function(n) {
Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.text + '"');
}
}

My JSON post looks like this:

{"action":"Customer","method":"getTree","data":["0"],"type":"rpc","tid":3}

evant
16 Jun 2009, 9:37 AM
You need to use either paramOrder or paramsAsHash.

gurufaction
16 Jun 2009, 10:52 AM
I was using paramOrder incorrectly. I thought I had to include the node parameter:


paramOrder: ['node','type']
should have been this:


paramOrder: ['type']


This small detail should probably be added to the documentation for use newbies :)

jitu
16 Jun 2009, 11:00 PM
hi,
I read Ext.Direct.....
but what is the perpose of this....
how can I use this in my script...

Rothariger
17 Jul 2009, 4:02 PM
i cant make it work...
i can see that the response is well formed, but the tree is not populated...

thanks!!!

elishnevsky
17 Jul 2009, 4:19 PM
i cant make it work...
i can see that the response is well formed, but the tree is not populated...

thanks!!!

Try setting paramsAsHash:false

Rothariger
17 Jul 2009, 5:02 PM
neither...

im using the same response as the example posted above...


ps: i found that in the example, in the parseResponse, the response is encoded to an array, but in my example it doesnt...

evant
17 Jul 2009, 6:57 PM
If you're using the .NET router, try grabbing the latest version, it has an example.

Rothariger
18 Jul 2009, 5:05 AM
i found that at mmy last try last night.
in the example of router y works like a charm, but in my project it throws a exception in this.directfn.apply...

thanks for your time...

dazuiba
26 Sep 2009, 6:40 AM
You should change your DIRECT API. set the len to a proper value.


{name: 'getTree', len: 2},

Quote:
Originally Posted by Rothariger https://67.228.178.42/forum/images/buttons/viewpost.gif (https://67.228.178.42/forum/showthread.php?p=360203#post360203)
i cant make it work...
i can see that the response is well formed, but the tree is not populated...

thanks!!!

Try setting paramsAsHash:false

on2wheels
27 Jan 2010, 2:14 PM
I've modified the direct-tree.js example page slightly to use Direct and can't get it to work. Here's some sample code from the page:



Ext.onReady(function(){
Ext.Direct.addProvider(iXdirect);

var tree = new Ext.tree.TreePanel({
width: 400,
height: 400,
autoScroll: true,
renderTo: document.body,
root: {
id: 'root',
text: 'toot'
},
loader: new Ext.tree.TreeLoader({
directFn: iX.Tree.GetTreeData('sdthgn', 'klmmy')
}),
fbar: [{
text: 'Reload root',
handler: function(){
tree.getRootNode().reload();
}
}]
});
});


The above code does return the correct data from the Direct call but the tree never loads. The little load animated icon just spins. What am I doing wrong?

on2wheels
28 Jan 2010, 8:38 AM
I'm officially confused. The below worked but now it doesn't...go figure. So I edited my post so you know that now it's not working when I know for a fact that it was passing the parameters. Now, it's not passing any parameter other than the root node's ID, and the data coming back (for testing) is properly formatted but will only load in the tree if I don't pass any parameters...PLEASE HELP!!!

--ORIG POST BELOW--

Well, after playing around with it for awhile, I got the parameters to pass correctly and now I'm getting the data back as seen using firebug but the tree still won't load the nodes. Here's the code I have now:



Ext.onReady(function(){
Ext.Direct.addProvider(iXdirect);

var tree = new Ext.tree.TreePanel({
width: 400,
height: 400,
autoScroll: true,
renderTo: document.body,
root: {
id: 'root',
text: 'root'
},
loader: new Ext.tree.TreeLoader({
directFn: iX.Tree.GetTreeData,
baseParams: {
cid: 'xyz',
uid:'abc'
},
paramOrder: ['cid','uid']
}),
fbar: [{
text: 'Reload root',
handler: function(){
tree.getRootNode().reload();
}
}]
});
});
Any ideas? I really need to get this working quickly. As that happens on the UI side is I click to expand the root node, it makes the Direct calls, gets the data back, and the tree does nothing other than display the Root node with a spinning loading image.

Please help!!!

axpa
19 Feb 2010, 8:39 AM
Any ideas? I really need to get this working quickly. As that happens on the UI side is I click to expand the root node, it makes the Direct calls, gets the data back, and the tree does nothing other than display the Root node with a spinning loading image.

Please help!!!
I'm also looking into why my directFn gets called but I currently dont get any nodes loaded nor is the loaders "load" event triggered.
Did you find any answers?
My problem was some weird caching problem on my side, so mine worked actually

Hmm, problem persist on a new treepanel, so here I go again debugging, has anyone found any solution?

I found that I by misstake returned metadata as well. Verify the node data you return if you have this problem.

Somethings not 100% ok, I can see in firebug that line 51281 processDirectResponse
response.status == true but still single steps down to this.handleFailure .
Strange.

tungchau
12 Mar 2010, 3:50 PM
I have the exact same problem that "on2wheels" was having. I am using ExtJS 3.1.1. I wonder if anybody out there had this problem solved. Please share your solution.

Stju
27 Apr 2010, 9:11 AM
Actually I would propose this as a BUG!
If You set at server side to receive at least one parameter (call it 'dummy' or whatever You like), it WORKS.
If receiving function has no parameters, despite of well and correctly formatted response data - animated wheel keeps spinning forever.
Took me a while to figure it out, as it is not even documented!
This BUG made me some disappointment, hopefully it will be FIXED and anyone else passing will notice this and save the time :)

mkramb
1 Feb 2011, 3:17 PM
Why is this still this way? I wasted many hours on this FEATURE.
It does not work if direct function accepts no parameters.

Condor
2 Feb 2011, 1:43 AM
It's not a bug. You just have to realize that the node id is ALWAYS passed to directFn, even if you don't define it in your paramOrder (so I would recommend specifying the nodeParameter in the paramOrder, so you don't get confused).

If really don't want the the node parameter to be passed (which is only useful if you have a single level tree), then you could override the getParams method of the loader.

Stju
2 Feb 2011, 10:34 AM
Then it should be documented! Otherwise You must have extraterrestrial knowledge to guess it.. ;)

angeldimitrov
30 May 2011, 6:09 AM
agree