您的位置:首页 > 产品设计 > UI/UE

easyui treegrid 动态展开数据(暂记)

2018-01-04 20:43 337 查看
ClassifyAdminSynMsgSvr.GetCLFLList("<%=CurUTag %>", 1, "", function (ret) {
//console.log(ret);
//console.log(ret._Items);
var zhdata = ret._Items;
var fileds = "FLID,DEEP,FLMC";
//获取已转为符合treegrid的json的对象
var nodes = ConvertToTreeGridJson("FLID", "FLID", "DEEP", fileds);
//
$(ret._Items).each(function (i, o) {
$.extend(o, { children: []})
});
console.log(JSON2.stringify(nodes));
$('#ClassifyTree').treegrid({
data: ret._Items,
idField: 'FLID',
treeField: 'FLID',
width: '33%',
height: '500',
pagination: false, rownumbers: true, singleSelect: true,
toolbar: [{
iconCls: 'icon-edit',
text: '编辑',
handler: function () {
$("#dlg").dialog("open");
}
}, {
iconCls: 'icon-add',
text: '增加',
handler: function () {
$("#dlg").dialog("open");
}
}, {
iconCls: 'icon-no',
text: '删除',
handler: function () { }
}],
loadFilter: myLoadFilter,
onClickRow: function (index, row) {
console.log(row);
//getGetFLMXList(row["FLID"]);
//GetFLPrtList(row["FLID"]);
},
columns: [[
{ field: 'FLID', title: '材料编号', width: '40%', align: 'left' },
{ field: 'FLMC', title: '材料分类', width:'50%', align: 'left' },
]]
});
});
function myLoadFilter(data, parentId) {
function setData() {
var todo = [];
for (var i = 0; i < data.length; i++) {
todo.push(data[i]);
}
while (todo.length) {
var node = todo.shift();
if (node.children) {
node.state = 'closed';
node.children1 = node.children;
node.children = undefined;
todo = todo.concat(node.children1);
}
}
}
setData(data);
var tg = $(this);
var opts = tg.treegrid('options');
opts.onBeforeExpand = function (row) {
var secondData= ClassifyAdminSynMsgSvr.GetCLFLList("<%=CurUTag %>", 2, row.FLID);

if (secondData && !row.children) {
tg.treegrid('append', {
parent: row[opts.idField],
data: secondData._Items
});
row.children1 = undefined;
}
return row.children1 == undefined;
};
return data;
}
<link href="../../Scripts/jquery-easyui-1.5/themes/default/easyui.css" rel="stylesheet" />
<link href="../../Scripts/jquery-easyui-1.5/themes/icon.css" rel="stylesheet" />
<script src="../../Scripts/jquery.min.js"></script>
<script src="../../Scripts/jquery-easyui-1.5/jquery.easyui.min.js"></script>
<script src="../../Scripts/jquery-easyui-1.5/locale/easyui-lang-zh_CN.js"></script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: