1.获取数据
var A = new Ext.ux.maximgb.tg.AdjacencyListStore({
autoLoad: false,proxy: new Ext.data.HttpProxy({
url: 'cfg.php?controller=app&action=showList'
}),
reader: new Ext.data.JsonReader({
root: 'data',
id: '_id'
}, [{name: 'name' }, {name: 'desc'}, { name: '_id',type: 'int'},
{name: '_level', type: 'int' }, { name: '_lft', type: 'int'},
{name: '_rgt', type: 'int'}, {name: '_is_leaf',type: 'bool'},
{name: '_parent', type: 'auto'}])
});
/*A.on('load', function (e) {
A.expandNode(A.getAt(0))
});*/
2.把获取的数据渲染到GridPanel中
var B = new Ext.ux.maximgb.tg.GridPanel({id: 'sysAppGrid',
title: '系统内置协议',
border: true,
store: A,
master_column_id: 'name',
columns: [
{id: 'name', header: "协议名", width: 250,sortable: false,dataIndex: 'name'},
{id: 'desc', header: "协议描述", width: 160,sortable: false,dataIndex: 'desc'}],
stripeRows: true,
autoExpandColumn: 'desc',
tbar: ['-', new Ext.Action({
iconCls: 'icon-collapse-all',
tooltip: '收起所有',
handler: function () {
var a = Ext.getCmp('sysAppGrid').store;
a.collapseAll()
}
}), '-', new Ext.Action({
iconCls: 'icon-expand-all',
tooltip: '展开所有',
handler: function () {
var a = Ext.getCmp('sysAppGrid').store;
a.expandAll()
}
})],
viewConfig: {
enableRowBody: true
}
});
B.on("cellclick", function (a, b, c, e) {
var d = a.getStore().getAt(b);
if (A.isExpandedNode(d)) {
A.collapseNode(d)
} else {
A.expandNode(d)
}
});