View Full Version : Tree with childrem + Data Base Mysql

14 Jun 2011, 7:14 AM
I'm using the example of this page http://www.sencha.com/learn/Tutorial:Ext20_Tree_TreeLoader_PHP_MySQL to create a dynamic tree with children.

The problem is I have a number of items and one of them must be a submenu, that is, they must deploy and display other items.

I do not know how to capture the event when it displays the folder to display and update the parameter subintems receiving php class example above to display the subitems.

I'm doing in the following way but I can not work.

var tree = new Ext.tree.TreePanel({
id: 'tree_maestro',
//title: 'Sample Layouts',
split: true,
//height: 300,
minSize: 150,
autoScroll: true,

// tree-specific configs:
rootVisible: false,
lines: false,
singleExpand: true,
useArrows: true,

loader: new Ext.tree.TreeLoader({
dataUrl: 'models/menu/list.php',
baseParams: {node:'0'}


root: new Ext.tree.AsyncTreeNode({
//id : 0

tree.addListener('load', function(node){
params = tree.getLoader().baseParams;
params.node='14';Appreciate any help I can offer

15 Jun 2011, 6:32 AM
Any idea?

I give you a screenshot. As you can see the problem is that I repeated in the main submenu items instead of charging the appropriate items.


16 Jun 2011, 2:11 PM
Any idea?

17 Jun 2011, 9:20 AM
I couldn't really understand your description of the problem but I think I figured it out from your screenshot.

Make sure you're using something like Firebug to watch the requests sent by the loader to the server. This can be very enlightening.

By default the loader will send off the node's id to the server, using the parameter configured using the nodeParameter config setting. Under most circumstances this should prove sufficient and there is no need to use any trickery using listeners or baseParams.

However, if you want to send other properties of the node you can use the beforeload event (not load as you're using in your code) to manipulate the loader's baseParams immediately prior to the request being made. Though you could do this on the treepanel (like your current code) it'd be better just to add a listeners block to your treeloader.

17 Jun 2011, 11:42 AM
Thanks for answering, now I understand how it works. What is not is like firebug check through what is the value that sends code.

Would be helpful if I explain how to view such values, because if I do not see the code and do a console.log not how.

17 Jun 2011, 12:01 PM
Fixed. The mistake was that I was using an id string. Converted to int the id and it worked perfectly.

Just like I know how to make the parameter debbug code?

It is possible to debud PHP code with firebug + FirePHP?

17 Jun 2011, 3:14 PM
Just like I know how to make the parameter debbug code?

I'm afraid I don't understand the question. I'll have a go at explaining some of the basics of debugging though, see if that helps. Firefox's Firebug and the Chrome Developer Tools are both quite similar, this advice applies to both.

You can view all the HTTP requests made by your application; seeing the request parameters, headers as well as the response.
They feature tools for inspecting and dynamically editing the HTML/DOM and CSS of your page.
The JavaScript console will show error messages with stacktraces, allowing you to dig into any errors that are thrown. The JavaScript consoles also allow you to run any arbitrary code at any point. It is where the output of calls to console.log() and console.dir() is shown, providing a simple way to do debug logging though you should remove such logging once you have finished debugging an issue.
The Script tabs allow you to view all of the JavaScript source for your application. You can insert breakpoints and conditional breakpoints that will pause application execution and allow you to inspect the stack and variables and step through execution of code from that point onwards.

In all cases you need to use ext-all-debug.js if you want to do meaningful debugging. I've generally found Chrome easier to work with on such a large JS file, with ctrl+G (go to line) and ctrl+f (find) both being very useful when trying to insert breakpoints in the right place.

It is possible to debud PHP code with firebug + FirePHP?

I don't know.

17 Jun 2011, 3:38 PM
Thank you very much for the explanation. I understand some things they did not understand.

I just need practice.

I am grateful for the help.