1

jqgrid 中的动态列名问题得到没有列名和数据的空白网格?在 jqgrid 中获取平淡无奇的网格 nocolumn 名称和日期这是我的代码我无法找到为什么我得到空白网格我正在使用 loadcoplete 事件和 ajax 调用

在此先感谢这是我的代码

<script type="text/javascript">

var jq = jQuery.noConflict();
    jq(function() {
        jq("#grid").jqGrid({

    url:'<%= request.getContextPath() %>/admin/dataGrid',
    datatype: "json",
    colNames:['','','','','',
              '','','','','',
              '','','','','', 
              '','','','','',
              '','','','','',
              '','','','',''],
    colModel:[
        {name:'p1',index:'p1', width:55,align:"right",hidden: true ,formatter:'date', formatoptions: {srcformat:'ISOLong', newformat:'H:i:s'}},
        {name:'p2',index:'p2', width:55,align:"right",hidden: true  },
        {name:'p3',index:'p3', width:55,align:"right",hidden: true },
        {name:'p4',index:'p4', width:55,align:"right",hidden: true },
        {name:'p5',index:'p5', width:55,align:"right",hidden: true },
        {name:'p6',index:'p6', width:55,align:"right",hidden: true},
        {name:'p7',index:'p7', width:55,align:"right",hidden: true},        
        {name:'p8',index:'p8', width:55,align:"right",hidden: true},
        {name:'p9',index:'p9', width:55,align:"right",hidden: true},
        {name:'p10',index:'p10', width:55,align:"right",hidden: true},
        {name:'p11',index:'p11',width:55,align:"right",hidden: true},
        {name:'p12',index:'p12',width:55,align:"right", hidden: true},
        {name:'p13',index:'p13',width:55,align:"right", hidden: true},
        {name:'p14',index:'p14',width:55,align:"right",hidden: true},   
        {name:'p15',index:'p15', width:55,align:"right",hidden: true},
        {name:'p16',index:'p16', width:55,align:"right",hidden: true},
        {name:'p17',index:'p17', width:55,align:"right",hidden: true},
        {name:'p18',index:'p18', width:55,align:"right",hidden: true},
        {name:'p19',index:'p19', width:55,align:"right",hidden: true},
        {name:'p20',index:'p20', width:55,align:"right",hidden: true},      
        {name:'p21',index:'p21', width:55,align:"right",hidden: true},      
        {name:'p22',index:'p22', width:55,align:"right",hidden: true},
        {name:'p23',index:'p23',width:55,align:"right",hidden: true},
        {name:'p24',index:'p24',width:55,align:"right", hidden: true},
        {name:'p25',index:'p25',width:55,align:"right", hidden: true},
        {name:'p26',index:'p26',width:55,align:"right",hidden: true},
        {name:'p27',index:'p27',width:55,align:"right",hidden: true},
        {name:'p28',index:'p28',width:55,align:"right", hidden: true},
        {name:'p29',index:'p29',width:55,align:"right", hidden: true},
        {name:'p30',index:'p30',width:55,align:"right",hidden: true},   
    ],
    postData: { 
    },
    rowNum:10,
    rowList:[10,20,30],
    height: 230,
    autowidth: true,
    rownumbers: true,
    pager: '#pager',
    viewrecords: true,
    emptyrecords: "Empty records",
    loadonce: false,
    viewrecords: true,
    caption:"Meter Data",
    footerrow: true,
    userDataOnFooter: true,
    loadComplete: function() {
         alert("load");
        /*   $ ("#grid").jqGrid('jq',{datatype:'json'}); */
    },
    jsonReader : {
        root: "rows",
        page: "page",
        total: "totalPages",
        records: "records",
        repeatitems: false,
        cell: "cell",
        userdata    : "userdata"

    },
  json : function(jsondata){

        $.ajax({
            url : '<%= request.getContextPath() %>/admin/dataGrid',
            data : jsondata,
            dataType :"json",
            complete: function(jsondata,stat)
            {
                if(stat=="success"){
                    var thegrid = jQuery("#grid")[0];
                    thegrid.addJSONData(eval("("+jsondata.responseText+")"))
                }
            }
        })
    } 
}); 

jq("#grid").jqGrid("setLable",23,"Column23");
jq("#grid").jqGrid("showCol",23); 
        jq("#grid").jqGrid('navGrid','#pager',
                {edit:false,add:false,del:false,search:true},
                { },
                { },
                { }, 
                { 
                    sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'],
                    closeOnEscape: true, 
                     }
        );
});


</script>  
4

0 回答 0