jqgrid表格列动态加载的实现
选中几个测点名,在表格中就显示几列。
具体代码如下:
function reloadGrid(postData){ $('#gridTable').jqGrid('GridUnload'); var newOption = $.extend(true,{},gridOption); newOption.postData = postData; if(postData.pointInfos){ var pointInfos = $.parseJSON(postData.pointInfos); var pointNames = [],pointCols = []; for(var prop in pointInfos){ pointNames.push(pointInfos[prop]); } for(var i = 0;i < pointNames.length;i++){ var name = pointNames[i]; pointCols.push({ label : name, name : name, sortable : false, width : 80 }); } } newOption.colModel = addColModel(pointCols); $('#gridTable').jqGrid(newOption); }