easyui datagrid 动态表头配置

 //动态表头配置
    var arrays = [];

    var columnFileds = $("#contractNoList").datagrid("getColumnFields");
    for (var i = 0; i < columnFileds.length; i++) {
        var opt = $("#contractNoList").datagrid("getColumnOption", columnFileds[i]);
        arrays.push({ field: opt.field, title: opt.title, width: 120, hidden: false, checkbox: opt.field == 'ck' ? true : false });
    }
    var columnsArray = [];
    columnsArray.push(arrays);
    $("#uploadProductDiv").dialog('open');
    $('#preUploadFile').datagrid({
        sortName: 'pcode',
        sortOrder: 'asc',
        nowrap: true,
        fitColumns: true,
        striped: true,
        collapsible: true,
        pageList: [10, 15, 30],
        singleSelect: true,
        columns: columnsArray
    });

posted @ 2018-09-20 14:09  lbja2  阅读(428)  评论(0编辑  收藏  举报