jQuery MiniUI

标题: 如何 遍历动态生成grid 列 [打印本页]

作者: liujun_0104    时间: 2015-5-22 10:30:51     标题: 如何 遍历动态生成grid 列


function createGrid() {
  var length=5;
  for(var i=0;i<=length;i++){

    grid.set({
        columns: [
            { type: "indexcolumn" },
            { field: "loginname", width: 120, headerAlign: "center", allowSort: true, header: "员工账号", editor: { type: "textbox", minValue: 0, maxValue: 200, value: 25} },
            { field: "age", width: 100, headerAlign: "center", allowSort: true, header: "年龄", editor: { type: "spinner"} },
            { field: "birthday", width: 100, headerAlign: "center", dateFormat: "yyyy-MM-dd H:mm", allowSort: true, header: "生日", editor: { type: "datepicker"} },
            { field: "remarks", width: 120, headerAlign: "center", allowSort: true, header: "备注", editor: { type: "textarea"} },
            { field: "gender", type: "comboboxcolumn", autoShowPopup: true, width: 100, headerAlign: "center", header: "性别", editor: { type: "combobox", data: Genders} },
            { field: "country", type: "comboboxcolumn", width: 100, headerAlign: "center", header: "国家", editor: { type: "combobox", url: "../data/countrys.txt"} },
            { field: "married", trueValue: 1, falseValue: 0, type: "checkboxcolumn", width: 60, headerAlign: "center", header: "婚否" },
            { field: "myxm"+i, trueValue: 1, falseValue: 0,  width: 60, headerAlign: "center", header: "myxm"+i }
         
        ]
    });
   

作者: felt    时间: 2015-5-22 10:43:28

var columns=grid.getColumns()
作者: liujun_0104    时间: 2015-5-22 11:03:34

felt 发表于 2015-5-22 10:43
var columns=grid.getColumns()

米有看明白   请具体点谢谢
作者: liujun_0104    时间: 2015-5-22 11:05:17

felt 发表于 2015-5-22 10:43
var columns=grid.getColumns()

    { field: "myxm"+i, trueValue: 1, falseValue: 0,  width: 60, headerAlign: "center", header: "myxm"+i }
我这行 任何动态 遍历生成5行  myxm1    myxm2     myxm3        myxm4    myxm5   等情况
作者: felt    时间: 2015-5-22 11:28:15

liujun_0104 发表于 2015-5-22 11:05
{ field: "myxm"+i, trueValue: 1, falseValue: 0,  width: 60, headerAlign: "center", header: "my ...

columns是一个数组,你动态添加直接数组里面加项
var columns=[] //固定的可以先放里面
for(....){
    var item={}    //动态生成的
    column.push(item);
}
grid.setColumns(columns)
作者: liujun_0104    时间: 2015-5-22 11:50:23

felt 发表于 2015-5-22 11:28
columns是一个数组,你动态添加直接数组里面加项
var columns=[] //固定的可以先放里面
for(....){



谢谢




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