jquery增加时编辑jqGrid(实例代码)
代码如下:
function showtestsubjectgrid() {
$("#testsubjectgrid").jqgrid({
url: "",
datatype: "json",
height: 215,
width: 480,
caption: "测试科目",
autoheight: true,
autowidth: true,
scrollrows: false, // 是否显示行滚动条
multiselect: true, // 是否显示复选框
hidegrid: false, //取消grid的收缩
postdata: {
strjson: testsubjectdata
},
colnames: ['', '测试科目', '开始时间', '结束时间', '场次', ],
colmodel: [
{
name: 'data',
index: 'data',
hidden: true
}, {
name: 'display_content',
index: 'display_content',
width: 100,
editable: true,
align: 'left'
}, {
name: 'exam_starttime',
index: 'exam_starttime',
width: 110,
editable: true,
align: 'center'
}, {
name: 'exam_endtime',
index: 'exam_endtime',
width: 110,
editable: true,
align: 'center'
}, {
name: 'exam_turn',
index: 'exam_turn',
width: 110,
editable: true,
align: 'center'
}],
jsonreader: {
root: "rows",
repeatitems: false,
id: "data"
},
gridcomplete: function () {
var testids = $("#testsubjectgrid").jqgrid("getdataids");
for (var i = 0; i < testids.length; i++) {
var cid = testids[i];
var exam_begintime = "<input type='text' name='exam_begintime_" + testids[i] + "' id='exam_begintime_" + testids[i] + "'/>";
var exam_endtime = "<input type='text' name='exam_endtime_" + testids[i] + "' id='exam_endtime_" + testids[i] + "'/>";
var exam_turn = "<input type='text' name='exam_turn_" + testids[i] + "' id='exam_turn_" + testids[i] + "'/>";
jquery("#testsubjectgrid").jqgrid('setrowdata', cid, { exam_starttime: exam_begintime });
jquery("#testsubjectgrid").jqgrid('setrowdata', cid, { exam_endtime: exam_endtime });
jquery("#testsubjectgrid").jqgrid('setrowdata', cid, { exam_turn: exam_turn });
$("#exam_begintime_" + testids[i]).datepicker({
showon: 'button',
buttontext: '选择'
});
nbsp; $("#exam_endtime_" + testids[i]).datepicker({
showon: 'button',
buttontext: '选择'
});
}
}
});
};
上一篇: Jquery绑定事件(bind和live的区别介绍)
下一篇: 世界之大,无奇不有