编辑列
第一种:
afterEditCell: function (id,name,val,iRow,iCol){
if (name == 'invdate') { //invdate是日期在colModel定义的name值
jQuery("#" + iRow + "_invdate", "#celltbl").datepicker({ dateFormat: "yy-mm-dd" }); //根据日期来判断这一行
}
},
afterSaveCell : function(rowid,name,val,iRow,iCol) {
if(name == 'amount') {
var taxval = jQuery("#celltbl").jqGrid('getCell',rowid,iCol+1);
jQuery("#celltbl").jqGrid('setRowData',rowid,{total:parseFloat(val)+parseFloat(taxval)});
}
第二种:
afterEditCell
:
function
(
id
,
name
,
val
,
iRow
,
iCol
)
{
if
(
name
==
'name'
)
{
//cities here is local json object
jQuery
(
"#"
+
iRow
+
"_name"
,
"#celltbl"
).
autocomplete
(
cities
);
}
},
afterSaveCell
:
function
(
rowid
,
name
,
val
,
iRow
,
iCol
)
{
if
(
name
==
'name'
)
{
jQuery
(
"#celltbl"
).
jqGrid
(
'setRowData'
,
rowid
,{
name
:
jQuery
(
".ac_over"
).
text
()});
jQuery
(
".ac_results"
).
remove
();
}
}
编辑行
ondblClickRow: function (id) {
if (id && id != lastsel) {
if (typeof lastsel != "undefined") {
$('#ExamsubjectGrid').jqGrid('saveRow', lastsel, null, "clientArray");
$('#ExamsubjectGrid').jqGrid('restoreRow', lastsel); //恢复行的状态
}
}
$('#ExamsubjectGrid').jqGrid('editRow', id, false);
lastsel = id;
}
本文介绍如何使用 jqGrid 进行单元格编辑及数据更新操作,包括日期选择器的集成、数据计算更新及下拉框的实现方法等。通过示例代码展示如何在编辑单元格后触发特定功能。
1181

被折叠的 条评论
为什么被折叠?



