PDA

View Full Version : Forums Example - forums-remote.php



MikeFi
8 Mar 2010, 11:47 AM
Hi,

I am having issues with getting the treeloader to display the forum names using the json response from the extjs forum example. The forum example queries http://extjs.com/forum/forums-remote.php for the json response to the list of forums. I have changed the proxy to be HttpProxy and have even manually hardcoded the response in json format but still no dice. Is there something i am missing. It doesnt look like the arguments that are needed are defined. Its not reading in the records. Firebug show that "o is null". Can someone explain what it is that forums-remote.php actually does. Is it just a json output of forum names? I see that there is a callback function defined...Do i need to do anything more than just have a json encoded string as an output? Do i need to accept any type of input? I have verified the json output in JSONLint and i know its correct because i copied and pasted the exact output that extjs.com had. Is it required to use ScriptTagProxy? I have it set to HttpProxy as the php script is local to the domain. Cant for the life of me get the tree loader to read and display the data.

Currently, the relevant config is as follows:


Forum.TreeLoader = function(){
Forum.TreeLoader.superclass.constructor.call(this);
this.proxy = new Ext.data.HttpProxy({
url : this.dataUrl
});
};

Ext.extend(Forum.TreeLoader, Ext.tree.TreeLoader, {
dataUrl: 'http://localdomain.com/json/enumforum.php',
requestData : function(node, cb){
this.proxy.request('read', null, {}, {
readRecords : function(o){
return o;
}
}, this.addNodes, this, {node:node, cb:cb});
},

addNodes : function(o, arg){
var node = arg.node;
for(var i = 0, len = o.length; i < len; i++){
var n = this.createNode(o[i]);
if(n){
node.appendChild(n);
}
}
arg.cb(this, node);
}
});
My enumforum.php looks like this:


[

{

"id": "10",

"text": "Ext JS Premium Forums",

"cls": "forum-ct",

"iconCls": "forum-parent",

"expanded": true,

"children": [

{

"id": "11",

"text": "Ext: Premium Help",

"cls": "forum",

"iconCls": "icon-forum",

"threads": "7732",

"totalPosts": 46727,

"leaf": true

},

{

"id": "4",

"text": "Ext: Feature Requests",

"cls": "forum",

"iconCls": "icon-forum",

"threads": "1222",

"totalPosts": 6943,

"leaf": true

}

]

},

{

"id": "22",

"text": "Ext General Forums",

"cls": "forum-ct",

"iconCls": "forum-parent",

"expanded": true,

"children": [

{

"id": "6",

"text": "Ext: Open Discussion",

"cls": "forum",

"iconCls": "icon-forum",

"threads": "3172",

"totalPosts": 28227,

"leaf": true

},

{

"id": "33",

"text": "Gxt: Open Discussion",

"cls": "forum",

"iconCls": "icon-forum",

"threads": "726",

"totalPosts": 4030,

"leaf": true

}

]

},

{

"id": "39",

"text": "Ext JS Community Forums (3.0)",

"cls": "forum-ct",

"iconCls": "forum-parent",

"expanded": true,

"children": [

{

"id": "40",

"text": "Ext: Help",

"cls": "forum",

"iconCls": "icon-forum",

"threads": "6662",

"totalPosts": 34932,

"leaf": true

}

]

}

]
Thanks!