- 注册时间
- 2019-4-4
- 最后登录
- 1970-1-1
- 阅读权限
- 10
- 积分
- 18
- 精华
- 0
- 帖子
- 0
|
html代码:<div id="treeGrid"></div>js代码:var columns = [
{type: 'indexcolumn'},
{field: 'menuName', header: '菜单名称', width: 'auto'},
{field: 'menuType', header: '类型', width: 50},
{field: 'orderNum', header: '排序', align: 'center', width: 48},
{field: 'url', header: '地址'},
{field: 'perms', header: '权限标示'},
{field: 'action', header: '操作', align: 'center'}
];
// 2、这里为grid赋值数据,只有这里成功了后面的调用才能成功。
grid = risk.setTreeGrid({
id: 'treeGrid',
options: {
ajaxType: 'get',
treeColumn:'menuName',
url: basePath + risk.getArrayItem(axios, 'key', 'list').url,
columns: columns
}
});setTreeGrid: function (grid) {
var defaults = {
url: '',
style: 'width:100%;height:400px;',
id: 'asyncDataGrid',
ajaxType: 'get',
columns: [],
multiSelect: true,
expandOnLoad: true,
allowResize: true,
allowCellEdit: true,
allowCellSelect: true,
allowRowSelect: true,
showPager: false,
showExpandButtons:true
};
var options = $.extend(defaults, grid.options);
//动态创建表格
var _grid = new mini.TreeGrid();
var _url = options.url;
delete options.url;
_grid.set(options)
_grid.render(document.getElementById(grid.id));
var treeList = risk.httpGet(_url).map(function (t) {
delete t.visible
return t
});
_grid.loadList(treeList,'id','parentId');
console.log(_grid.getRootNode())
return _grid;
}最终表格数据都有了,但是treeColumn不生效,没有树结构。
|
|