View Full Version : Tree, TreeLoader and asp.net

21 May 2007, 5:26 AM
I am new to Ext so sorry in advance for this question...
I try to use ext tree and asp.net together. I checked examples and all of them use treeloader class. In reorder example code looks like this:

var tree = new Tree.TreePanel('tree-div', {
loader: new Tree.TreeLoader({dataUrl:'get-nodes.php'}),
containerScroll: true

Is it possible to set dataUrl to aspx page and what should be on that page? Is it possible to call web service?? How can I get it work??

21 May 2007, 7:53 AM
You can pretty much use any language to get your tree data back. You just have to make sure that the format of your returned data is json. You can use a webservice but make sure that it doesn't wrap your response with extra stuff or it won't work (at least it didn't work when my response came back in a wddx packet but that may have just been me).

First thing I would do is have an aspx page simply output.

[{"text":"my tree item","id:"1",isLeaf:true},{"text":"my tree item 2","id:"2",isLeaf:true},{"text":"my tree item 3","id:"3",isLeaf:true}]

Then point your dataUrl to your aspx page and give it a shot.

Then create a webservice and simply output the static menu code above, call it via a browser and see what is returned..


22 May 2007, 8:31 PM
I am having a heck of a time loading a treepanel with asp.net I am getting closer.. I think.

Are there any complete examples available?

I have no problem building the JSON string, but I can not find a way to call the ajaxpro method in the dataUrl parameter. here is my aspx code..

public class MyClass

public string GetNodes()

return "[{\"text\":\"my tree item\",\"id:\"1\",isLeaf:true},{\"text\":\"my tree item 2\",\"id:\"2\",isLeaf:true},{\"text\":\"my tree item 3\",\"id:\"3\",isLeaf:true}]";

On server side page_load() I call...


And my javascript is...

loader: new Tree.TreeLoader({

So how do I call the GetNodes() method? Also, if there is a better way, please point me in the right direction.

Thank you!!

22 May 2007, 11:37 PM
Examples are in the documentation page, http://extjs.com/deploy/ext/docs/index.html

Specifically: http://extjs.com/deploy/ext/examples/tree/dependency.html

Setting the dataUrl in the TreeLoader is all you need to do on the Ext side. Any problem from then on is down to your server-side programming.

Are you using Firebug to check that the URL is being accessed and that data is coming back?

24 May 2007, 4:55 AM

The first thing I would do is get the json string from the online tree example code that is on this site found at http://extjs.com/deploy/ext/examples/tree/get-nodes.php. Copy that string and simply output it in an aspx file without any other markup (no html head title or body), then in your tree js reference that file in your dataurl, you could simply copy the example at http://extjs.com/deploy/ext/examples/tree/reorder.html and change the dataurl to point to your aspx page.

Once you have that actually working, then create a class and return the fixed tree json file, and then call your calls from your aspx output page, then get progressively more complex...eg create a webservice that supplies the json string..

Hope that helps, that method helped me get farther quicker and give me less frustration.



2 Jun 2007, 7:37 PM
Thank you. I took the route you suggested.. I am now using ATLAS to provide the JSON strings.. I tried ASP.NET PRO and Anthem.. but ATLAS seems to handle all my needs for now.

I really appreciate your direction, And I really appreciate these forums and this library.. I am AJAXing everything now :) of course only when needed though :)

Thanks again.

19 Sep 2007, 7:24 PM
If I may ask, how did you get the webservice to output just the string with no xml around it?

Or did you?