Code below sets default values for new row if row is added using form. If row is added using jqGrid inline add button from toolbar, those methods are not called and default values are not set.
• 如何在网上添加与以下法典相同的逻辑?
var lastSelectedRow;
$grid.navGrid("#grid_toppager", {
del: true,
add: true,
view: true,
edit: true
},
{},
{
addedrow: beforeSelected ,
url: /Grid/Add?_entity=Desktop ,
beforeInitData: function () {
// todo: how to call this method from inline add
var rowid = $grid.jqGrid( getGridParam , selrow );
if (rowid === null) {
alert( Select row before adding );
return false;
}
},
afterShowForm: function(formID) {
// todo: how to set default values as this method sets from inline add
var selRowData,
rowid = $grid.jqGrid( getGridParam , selrow );
$( # + Recordtype + .FormElement ).val( Veerg );
$( # + Nait2 + .FormElement )[0].checked = true;
selRowData = $grid.jqGrid( getRowData , rowid);
$( # + Baas + .FormElement ).val(selRowData.Baas);
$( # + Liigid + .FormElement ).val(selRowData.Liigid);
}
);
$grid.jqGrid( inlineNav , #grid_toppager , {
addParams: {
position: "beforeSelected",
rowID: _empty ,
useDefValues: true,
addRowParams: {
keys: true,
onEdit : onInlineEdit
}
},
editParams: {
editRowParams: {
onEdit : onInlineEdit
}
},
add: true,
edit: false,
save: true,
cancel: true
});
function onInlineEdit(rowId) {
if (rowId && rowId !== lastSelectedRow) {
cancelEditing($grid);
lastSelectedRow = rowId;
}
}
Update
I Trial Code
$grid.jqGrid( inlineNav , #grid_toppager , {
addParams: {
position: "beforeSelected",
rowID: _empty ,
useDefValues: true,
addRowParams: {
keys: true,
extraparam: { _dokdata: FormData },
onSuccess : function (jqXHR) {
alert( addp oncuss );
jqXHRFromOnSuccess=jqXHR;
return true;
},
afterSave: function (rowID) {
alert( afeesave addp );
cancelEditing($grid);
afterDetailSaveFunc(rowID,jqXHRFromOnSuccess);
jqXHRFromOnSuccess=null;
},
onError: errorfunc,
afterRestore : setFocusToGrid,
oneditfunc : function (rowId) {
var selRowData, selRowId ;
if (rowId && rowId !== lastSelectedRow) {
cancelEditing($grid);
selRowId = $grid.jqGrid( getGridParam , selrow );
if (selRowId ) {
selRowData = $grid.jqGrid( getRowData , selRowId );
$( # + rowId + _Reanr ).val(selRowData.Reanr);
}
lastSelectedRow = rowId;
}
}
}
}
);
只打电话给定点。 • 如何在Surccess、Save、Error等方法上强制使用?
<><>Update 2
我在解答和审判时建议ith除阴道。
$.extend( jQuery.jgrid.inlineEdit, {
addParams: {
position: "beforeSelected",
rowID: <%= EntityBase.NewRowIdPrefix %> ,
useDefValues: true,
addRowParams: {
keys: true,
extraparam: { _dokdata: FormData },
onSuccess : function (jqXHR) {
jqXHRFromOnSuccess=jqXHR;
return true;
},
afterSave: function (rowID) {
cancelEditing($grid);
<% if (Model is RowBase ) { %>
afterDetailSaveFunc(rowID,jqXHRFromOnSuccess);
<% } else { %>
afterGridSaveFunc(rowID,jqXHRFromOnSuccess);
<% } %>
jqXHRFromOnSuccess=null;
},
onError: errorfunc,
afterRestore : setFocusToGrid,
oneditfunc : function (rowId) {
if (rowId && rowId !== lastSelectedRow) {
cancelEditing($grid);
lastSelectedRow = rowId;
}
}
}
}
} );
本案不再逐条增加。 该法典的所有参数都被忽视。