The*_*att 2 javascript asp.net-mvc jquery jqgrid
我正在网格上进行内联编辑,但似乎无法触发与该编辑相关的任何事件.
在这里我有afterSubmit:我希望它在用户编辑网格中的Quantity字段后触发,但它永远不会触发.
$('#tblLines').jqGrid({
url: createUrl('/CRA/GetLines/'),
editurl: '/CRA/EditModifyLine',
emptyrecords: '',
datatype: 'json',
mtype: 'GET',
colNames: ['Group', 'Description', 'Quantity'],
colModel: [
{ name: 'Group', index: 'Group', width: 100, align: 'left' },
{ name: 'Description', index: 'Description', width: 400, align: 'left' },
{ name: 'Quantity', index: 'Quantity', width: 150, align: 'left', editable: true },
pager: jQuery('#pgrLines'),
rowNum: 10,
rowList: [5, 10, 20, 50],
sortname: 'Group',
sortorder: "desc",
viewrecords: true,
caption: 'Core Group Lines',
onSelectRow: function(id) {
$('#tblCoreGroupLines').editRow(id, true);
lastsel = id;
},
afterSubmit: function(response, postdata) {
alert('got here');
},
postData: { craId: $('#CraId').val() }
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试将事件定义为navControl的一部分,但这也不起作用.内联编辑工作正常 - POST成功,结果返回,它只是永远不会发生应该绑定它的事件.我已经尝试了所有与更改数量字段相关的事件,但它们都不起作用.
我是否在正确的地方定义了活动?我错过了网格上的属性还是什么?
我认为你需要传入afterSubmit属性参数editRow.
因此,你需要这样移动afterSubmit:
.....
onSelectRow: function(id) {
$('#tblCoreGroupLines').editGridRow(id, { afterSubmit: function(response, postdata) {
alert('got here');
}
});
lastsel = id;
},
...
Run Code Online (Sandbox Code Playgroud)
关于editGridRow的文档在这方面有所帮助.
上面的示例会导致模态(因为这是使用afterSubmit的唯一位置).如果您想在使用indline编辑成功更新后执行某些操作,则应该能够在onSelectRow中执行以下操作
$('#tblCoreGroupLines').editGridRow(id,true, undefined, function(res) {
// res is the response object from the $.ajax call
alert('success!!')
} );
Run Code Online (Sandbox Code Playgroud)
这是来自js/grid.inlineedit.js的editRow的方法签名
editRow : function(rowid,keys,oneditfunc,succesfunc, url, extraparam, aftesarvefunc,errorfunc, afterrestorefunc) {
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10583 次 |
| 最近记录: |