ExtJs4 tree无法显示

彩虹咖啡 2012-03-07 06:25:19
最近我使用Extjs4做了一个树,js代码如下,请各位大侠帮忙找找问题,为啥树显示不出来
Ext.onReady(function() {
Ext.Ajax.request( {
url : 'common_getMenuTree.action',
success : function(res) {
loadMenu(res, false)
}
});
});

function loadMenu(res, isupdate) {
var menuList = Ext.JSON.decode(res.responseText);
Ext.temp['menuList'] = menuList;
showLayout(menuList, "系统菜单", isupdate);
}


function showLayout(menuList, name, isupdate) {

var tabs = Ext.create('Ext.panel.Panel',{
region : 'center',
id : 'content_tabs',
contentEl : 'center-div',
deferredRender : false,
resizeTabs : true,
minTabWidth : 200,
tabWidth : 135,
height : 300,
autoScroll : true,
enableTabScroll : true,
items : []
});



var tree = create_tree(menuList, name);

//tabs.activate(0);

Ext.create('Ext.container.Viewport',{
layout : 'border',
items : [ {
region : 'north',
contentEL : 'north-div',
height : 30,
bodyStyle : 'background-color:#BBCCEE',
items : []
}, tree, {
region : 'center',
layout : 'border',
items : [ tabs ]
} ]

});
}


function create_tree(menuList, name) {
var root = Ext.create('Ext.data.NodeInterface',{
id : 'treeRoot',
text : 'ENESYS菜单',
expanded: true,
children : menuList
});

var store = Ext.create('Ext.data.TreeStore',{
model:'TreeNode',
autoLoad:true,
root: root
});
/*var store = Ext.create('Ext.data.TreeStore',{
proxy: {
type: 'ajax',
url: 'common_getMenuTree.action'
},
reader:{
type:'json'
},
root: {
id : 'treeRoot',
text : 'ENESYS菜单',
expanded: true,
}
});*/


var tree = Ext.create('Ext.panel.Panel',{
region : 'west',
id : 'opreationTree',
contentEl : 'west-div',
activeItem:0,
enableDD : false,
useArrows : true,
title : name,
split : true,
width : 300,
minSize : 175,
maxSize : 400,
collapsible : true,
margins : '0 0 0 0',
autoScroll : true,
collapsed:false,
store: store
});
tree.on('contextmenu', create_right_click_menu, tree);
document.oncontextmenu = function(e, t) {
if (e || e.stopPropagation) {
e.stopPropagation();
} else {
window.event.CancelBubble = true;
}
return false;
}
tree.on('click',create_click_event,tree);
tree.on('checkchange', function(node, flag) {
var checkflag = node.attributes.checked;
if (node instanceof Ext.data.NodeInterface && node.hasChildNodes()) {

node.expand(true, false, function(pnd) {
pnd.eachChild(function(child) {
child.ui.toggleCheck(checkflag);
child.attributes.checked = checkflag;
checkchangeListner(child,checkflag);
}, pnd);
});
if(!checkflag){
node.collapse(true);
}
}
}
);

return tree;
}
...全文
408 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

52,782

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧