PDA

View Full Version : ExtJS 4 Remote Treepanel Error



talha06
15 May 2012, 5:49 AM
I'm trying to load my treepanel; everything is OK if all of them are leaves. But if one of them has children, I'm able to render but when I click to expand it, it gives an error like this:

records[i] is undefined
ns[i].viewRecordId = records[i].internalId;

Here's the data that I load:


{
"data": [{
"active": 1,
"adminOnly": 0,
"iconCls": "icon-boss",
"menuId": 1,
"order": 1,
"text": "About Me",
"upMenuId": 0,
"view": "panel.AboutPanel",
"leaf": false,
"children": [{
"active": 1,
"adminOnly": 0,
"iconCls": "",
"menuId": 11,
"order": 11,
"text": "Biography",
"upMenuId": 1,
"view": "panel.AboutPanel",
"leaf": true
}]
}, {
"active": 1,
"adminOnly": 1,
"iconCls": "icon-key",
"menuId": 2,
"order": 2,
"text": "Admin Panel",
"upMenuId": 0,
"view": "panel.AboutPanel",
"leaf": true
}, {
"active": 1,
"adminOnly": 0,
"iconCls": "icon-users",
"menuId": 4,
"order": 4,
"text": "User List",
"upMenuId": 0,
"view": "user.UsersGrid",
"leaf": true
}, {
"active": 1,
"adminOnly": 1,
"iconCls": "icon-menu",
"menuId": 6,
"order": 6,
"text": "Menu List",
"upMenuId": 0,
"view": "menu.MenusGrid",
"leaf": true
}, {
"active": 0,
"adminOnly": 0,
"iconCls": "icon-user",
"menuId": 8,
"order": 8,
"text": "User Panel",
"upMenuId": 0,
"view": "user.UserPanel",
"leaf": true
}, {
"active": 1,
"adminOnly": 0,
"iconCls": "icon-pie-chart",
"menuId": 9,
"order": 9,
"text": "User Stats",
"upMenuId": 0,
"view": "user.UserChart",
"leaf": true
}, {
"active": 1,
"adminOnly": 0,
"iconCls": "icon-card",
"menuId": 10,
"order": 10,
"text": "Card Registeration",
"upMenuId": 0,
"view": "card.CardPanel",
"leaf": true
}],
"totalCount": 7,
"success": true
}

I'll be happy if someone can helps me.
Thanks in advance.
Regards..

vietits
15 May 2012, 5:59 AM
Try to fix your returned data as below (using 'data' instead of 'children'):


{
"data": [{
"active": 1,
"adminOnly": 0,
"iconCls": "icon-boss",
"menuId": 1,
"order": 1,
"text": "About Me",
"upMenuId": 0,
"view": "panel.AboutPanel",
"leaf": false,
// "children": [{
"data": [{
"active": 1,
"adminOnly": 0,
"iconCls": "",
"menuId": 11,
"order": 11,
"text": "Biography",
"upMenuId": 1,
"view": "panel.AboutPanel",
"leaf": true
}]
}, {

talha06
15 May 2012, 6:01 AM
Thanks a lot vietits, it solved my problem.. =D>