首先ajax取数据
$.ajax(
{
type: "get",
url: "../../MECManage/TJYY/collect",
cache: false,
async: false,
data: { coljson: JSON.stringify(coljson) },
dataType: 'json',
error: function () {
alert("数据出错!");
},
success: function (data) {
DrawListTwo(data,gridTables)
//后面的参数是放表格table的ID
}
function DrawListTwo(data, id) {
var colModelData = [{ name: "clus_code", label: "编号", hidden: true },
{ name: "clus_name", index: "clus_name", label: "套餐", 130 }, { name: "price", label: "价格", '55px' }, {
name: "process",
index: "process",
label: "操作",
125,
sortable: true,
align: 'center'
}
];
var $gridTables = $("#" + id);
$gridTables.jqGrid({
datatype: "local",
styleUI: 'Bootstrap',
data: data.lnc,
height: 550,
auto true,
colModel: colModelData,
sortorder: 'desc',
rownumbers: true,
shrinkToFit: false,
//height: 340,
viewrecords: true,
gridComplete: function () {
var ids = jQuery("#gridTables").jqGrid('getDataIDs');
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
update = "<input type='button' value='编辑' onclick='updateCollect(" + cl + ")'/> ";
copy = "<input type='button' value='复制' onclick='deleteStu("
+ cl + ")'/> ";
delet = "<input type='button' value='删除' onclick='viewStu("
+ cl + ")'/>";
jQuery("#gridTables").jqGrid('setRowData',
ids[i], {
process: update + copy + delet
});
}
}
});
}