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>
//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>
相关文章推荐
- EasyUI的treegrid 递归动态 填充数据
- EasyUI的treegrid组件动态加载数据问题解决办法
- EasyUI的treegrid组件动态加载数据问题的解决办法
- EasyUI的treegrid组件动态加载数据问题的解决办法
- EasyUI的treegrid组件动态加载数据问题的解决办法-jquery
- EasyUI DataGrid动态加载数据
- easyUI框架下的select下拉框动态加载数据库中数据
- easyui tree datagrid动态添加表头和表格数据,动态弹出框,修改和删除按钮
- Easyui笔记4:实现表格内combobox数据的动态切换(getEditor的使用)
- EasyUI datagrid动态加载json数据
- 如何清除或初始化 easyui 的 treegrid 控件的数据
- 【项目实战】---为EasyUI DataGrid的某一动态加载数据列添加超链接,点击超链接触发Onclick方法
- Easyui笔记4:实现表格内combobox数据的动态切换(getEditor的使用)
- EasyUI 1.3.1 datagrid动态绑定列名和数据
- 【easyui】 jq 表单返回的数据,动态增加部分数据后,提交到后台进行处理
- EasyUI动态表头与数据宽度不对应
- easyui-datagrid动态修改url,实现datagrid中数据的更新变化
- 使用RecycleView实现动态获取数据展开二级列表展示
- easyui动态加载表格并绑定数据