jQuery MiniUI

标题: treegrid 动态加载请教 [打印本页]

作者: dapang    时间: 2013-4-3 11:42:15     标题: treegrid 动态加载请教

treegrid 定义:
<div id="ml_total" class="mini-treegrid" treeColumn="xm1" style="width:100%;height:100%;" showTreeIcon="true" idField="xm" parentField="xm0" resultAsTree="false"></div>

表头定义:
var col_str = [{ "field": "xm", "name": "xm", "width": "50", "align": "center", "headerAlign": "center", "header": "序号" }, { "field": "xm1", "name": "xm1", "width": "50", "align": "center", "headerAlign": "center", "header": "类别" }, { "field": "xm2", "name": "xm2", "width": "50", "align": "center", "headerAlign": "center", "header": "条数" }, { "header": "错误条数", "headerAlign": "center", columns: [{ "field": "xm3", "width": "50", "align": "center", "headerAlign": "center", "header": "合计" }, { "field": "xm4", "width": "50", "align": "center", "headerAlign": "center", "header": "苗子" }, { "field": "xm5", "width": "50", "align": "center", "headerAlign": "center", "header": "甲" }, { "field": "xm6", "width": "50", "align": "center", "headerAlign": "center", "header": "乙" }, { "field": "xm7", "width": "50", "align": "center", "headerAlign": "center", "header": "丙"}]}];


数据文件TJ.TXT内容:
[{xm:'1',xm0:-1,xm1:'命令总数',xm2:'195',xm3:'0',xm4:'0',xm5:'0',xm6:'0',xm7:'0'},{xm:'2',xm0:'1',xm1:'H',xm2:'17',xm3:'',xm4:'',xm5:'',xm6:'',xm7:''},{xm:'3',xm0:'1',xm1:'A',xm2:'10',xm3:'',xm4:'',xm5:'',xm6:'',xm7:''},{xm:'4',xm0:'1',xm1:'B',xm2:'7',xm3:'',xm4:'',xm5:'',xm6:'',xm7:''},{xm:'5',xm0:'1',xm1:'B',xm2:'10',xm3:'',xm4:'',xm5:'',xm6:'',xm7:''},{xm:'6',xm0:'1',xm1:'D',xm2:'15',xm3:'',xm4:'',xm5:'',xm6:'',xm7:''},{xm:'7',xm0:'1',xm1:'E',xm2:'10',xm3:'',xm4:'',xm5:'',xm6:'',xm7:''}]

代码:
            var grid1 = mini.get("ml_total");
            grid1.setColumns(col_str);
            grid1.setUrl("scripts/tj.txt");
            grid1.load();
运行后只能显示表头,没有数据。不知哪里出错了。

作者: niko    时间: 2013-4-3 12:24:38

1)height为auto
2)tj.txt注意大小写
3)grid1.load()去掉
4)更新下最新版本:http://www.miniui.com/download/




欢迎光临 jQuery MiniUI (http://miniui.com/discuss/) Powered by Discuz! X2