日期:2014-05-16  浏览次数:20625 次

Ext4 Tree读不出来数据,高手帮忙看看哪错了

Ext.regModel("TreeMenu",{
    fields:[
    {name: 'parentid',     type: 'string'},
    {name: 'text',     type: 'string'}
    ]
});

var store = new Ext.data.TreeStore({
    model:'TreeMenu',
    nodeParam:'parentid',  //指定节点参数名
    proxy:{
        type: 'ajax',
        url: 'TreeMenu.aspx',
        reader:'json'
    },
    autoLoad:true,
    root:{
        text:'根节点',
        parentid:'-1'
    }
});

var treenode = Ext.create('Ext.tree.Panel',{   
    store: store, 
    columns:[{
        xtype:'treecolumn',
        dataIndex:'text',
        sortable:true
    }],
    width:250,
    height:150,
    lines:false,
    useArrows : true,
    rootVisible:false,
    rootVisible: false
});


返回JSON数据

[{id:"1",menucode:"xhfp",text:"发票管理",parentid:"0",leaf:false,iconCls:""},
{id:"2",menucode:"tjcx",text:"统计查询",parentid:"0",leaf:false,iconCls:""},
{id:"3",menucode:"jczl",text:"基础资料",parentid:"0",leaf:false,iconCls:""},
{id:"4",menucode:"qxgl",text:"权限管理",parentid:"0",leaf:false,iconCls:""},
{id:"5",menucode:"xtsz",text:"系统设置",parentid:"0",leaf:false,iconCls:""}]

------解决方案--------------------

    sorters:[{
        property:'text',
        direction:'ASC'
    }]

在 Ext.data.TreeStore添加以上代码