我使用jqgrid,在内联编辑中,在用户编辑特定单元格值后,他需要按“Enter”按钮进行更新,但我需要在用户离开单元格时直接更新它。
jQuery代码
<script type="text/javascript">
$(function () {
var lastsel;
var colind = 2;
jQuery("#list").jqGrid({
url: '/Home/GetStudents/',
datatype: 'json',
mtype: 'POST',
colNames: ['StudentID', 'FirstName', 'LastName', 'Email'],
colModel: [
{ name: 'StudentID', sortable: false, key: true },
{ name: 'FirstName', key: true },
{ name: 'LastName', sortable: false, key: true },
{ name: 'Email', width: 200, sortable: false, key: true}],
cmTemplate: { align: 'center', editable: true },
pager: '#pager',
width: 750,
rowNum: 15,
rowList: [5, 10, 20, 50],
sortname: 'StudentID',
sortorder: "asc",
viewrecords: true,
caption: ' My First JQgrid',
onSelectRow: function (StudentID)
// onCellSelect:function(StudentID)
{
if (StudentID != lastsel) {
jQuery('#list').jqGrid('restoreRow', lastsel);
jQuery('#list').jqGrid('editRow', StudentID, true);
// jQuery('#list').jqGrid('editCell', StudentID, colind, true);
lastsel = StudentID;
}
},
editurl: '/Home/About/',
// data: { get_param: selectedDescription },
caption: "jQgrid Sample"
});
jQuery("#list").jqGrid('navGrid', "#pager", { edit: false, add: false, del: false });
});
</script>