[英]jqGrid: Why aren't the events that I defined for a grid edit firing?
我正在網格上進行內聯編輯,但似乎無法觸發與該編輯相關的任何事件。
在這里我有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() }
});
我已經嘗試將事件定義為navControl的一部分,但這也不起作用。 內聯編輯工作正常 - POST成功,結果返回,它只是永遠不會發生應該綁定它的事件。 我已經嘗試了所有與更改數量字段相關的事件,但它們都不起作用。
我是否在正確的地方定義了活動? 我錯過了網格上的屬性還是什么?
我認為您需要將屬性參數中的afterSubmit
傳遞給editRow
。
因此,您需要移動afterSubmit
如下所示:
.....
onSelectRow: function(id) {
$('#tblCoreGroupLines').editGridRow(id, { afterSubmit: function(response, postdata) {
alert('got here');
}
});
lastsel = id;
},
...
關於editGridRow的文檔在這方面有所幫助。
上面的示例會導致模態(因為這是使用afterSubmit的唯一位置)。 如果您想在使用indline編輯成功更新后執行某些操作,則應該能夠在onSelectRow中執行以下操作
$('#tblCoreGroupLines').editGridRow(id,true, undefined, function(res) {
// res is the response object from the $.ajax call
alert('success!!')
} );
這是來自js / grid.inlineedit.js的editRow的方法簽名
editRow : function(rowid,keys,oneditfunc,succesfunc, url, extraparam, aftesarvefunc,errorfunc, afterrestorefunc) {
您還可以在editRow方法中使用aftersavefunc事件來獲取服務器響應,如果這是您要查找的唯一內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.