ajax异步加载TreeGrid数据,使用empty()清空原始数据
来源:互联网 发布:主题制作软件下载 编辑:程序博客网 时间:2024/05/16 17:11
$(document).ready(function(){var treeGrid;//初始化TreeGrid数据getTreeGridDate();});function getTreeGridDate(idMerchant){if(!idMerchant){idMerchant=-1;}$.ajax(type:"get",url:basePath + “xxx/xxx/xx.do?adt=”+new Date().getTime(),data:{"idMerchant":idMerchant},dataType:"json",success:function(data){//后端返回json格式的字符串if(data){$("div1").empty();//清空原来的TreeGridvar dataTreeGridSource = eval(data);//转成数组对象var config = { id: "tg1", width: "800", renderTo: "div1", headerAlign: "left", headerHeight: "30", dataAlign: "left", indentation: "20", folderOpenIcon: "images/folderOpen.gif", folderCloseIcon: "images/folderClose.gif", defaultLeafIcon: "images/defaultLeaf.gif", hoverRowBackground: "false", folderColumnIndex: "1", itemClick: "itemClickEvent", columns: [ { headerText: "", headerAlign: "center", dataAlign: "center", width: "20", handler: "customCheckBox" },{ headerText: "名称", dataField: "name", headerAlign: "center", handler: "customOrgName" },{ headerText: "拼音码", dataField: "code", headerAlign: "center", dataAlign: "center", width: "100" },{ headerText: "负责人", dataField: "assignee", headerAlign: "center", dataAlign: "center", width: "100" }], data:dataTreeGridSource }; //创建一个组件对象 treeGrid = new TreeGrid(config); treeGrid.show(); }else if(!data){$("div1").empty();$("div1").append("<table id=\"tg1\" ................暂无数据....");}},error:function(){alert("查询异常,请稍后再试或联系管理员。。。");}});}
如果是修改或者展示已经勾选的,则需要先查出已经勾选过的id数组,然后再在customCheckBox()方法中进行判断处理:
var idArray = ...;//从后台查询得到
function customCheckBox(row, col) {
for(var i in idArray){
if(idArray[i] == row.idOper){
return "<input type='checkbox' name='idCategory' value="+row.idOper+" check='checked'>";
}
}
return "<input type='checkbox' name='idCategory' value="+row.idOper+">";
}
此外empty()函数在做清除原来数据方面有很大作用。如级联下拉的清除也需要如此。
0 0
- ajax异步加载TreeGrid数据,使用empty()清空原始数据
- EASYUI TREEGRID异步加载数据
- jQuery EasyUI treegrid异步加载数据
- jquery easyui-datagrid/treegrid 清空数据参考
- TreeGrid 异步加载节点
- ext treegrid 异步加载
- treegrid 异步加载
- treegrid异步加载
- TreeGrid异步加载
- Ajax使用XML异步加载数据
- 使用原生ajax异步加载数据
- 使用Ajax异步加载请求JSON数据
- 使用easyUI的treegrid的时候,出现后台返回数据为空时,treegrid加载了前面请求到的数据到页面上的问题
- jqgrid——treegrid动态异步加载数据
- Jquery EasyUI TreeGrid异步加载
- ajax调用别的页面加载数据,数据被改变后,从新加载还是原始数据!
- 使用Ajax异步加载图片
- jQuery 清空div样式 $("#UserDivID").empty()
- Java基础--集合框架(Map集合)
- 抽象类和接口
- Towards Crazyswarms
- 第三十六课——简单文字处理
- Android Studio使用lambda
- ajax异步加载TreeGrid数据,使用empty()清空原始数据
- iOS新建项目架构规范
- iOS Default-568@2x.png启动图片设置问题
- 剑指offer系列之六十一:二叉树搜索树的第k个节点
- c++ note--二叉树的实现
- CocoaPod的安装及与Swift的桥接
- ssh 10个选项
- preg_match_all()匹配
- Html 排版与标签(一)