jqgrid inlineNav add – 在添加的行上显示保存图标

我使用jqgrid的inlineNav选项向工具栏添加“添加”选项。 我还使用动作格式化程序进行编辑和删除。 当我添加新行时,新添加的行具有编辑图标和取消图标,而保存图标位于添加旁边的工具栏上。

有没有办法指定新添加的行有一个保存和取消图标而不是编辑图标?

如果有人有类似的问题。

我最终滚动了自己的格式化程序。

inlineNavAction = function(cellvalue, options, rowObject, isSavedRow){ if(isSavedRow !== true){ var rowid = options.rowId; var ocl = "id='jSaveButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'save'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); "; var str = "
"; ocl = "id='jCancelButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'cancel'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); "; str += "
"; return "
" + str + "
"; }else{ return $.fn.fmatter.actions(cellvalue, options, rowObject); } }

isSavedRow在由于添加而保存行后再次调用格式化程序的情况下传递为true。 我还将rowId默认为0.默认操作为false。 我将标记保存并从github上可用的源代码中取消4.5版

用法:

 formatter: function(cellvalue,options,rowObject) { return inlineNavAction(cellvalue,options,rowObject, (options.rowId!='new_row')); } 

new_row in

 (options.rowId!='new_row') 

是您为添加的行设置为默认rowId的任何内容。 new_row是默认值。

action列的formatter更改为:

 formatter: function (cellvalue, options, rowObject) { if (cellvalue === undefined && options.rowId === "_empty") { // remove edit and del buttons options.colModel.formatoptions.editbutton = false; options.colModel.formatoptions.delbutton = false; } return $.fn.fmatter.actions(cellvalue, options, rowObject); }, 

然后在addParamsinlineNav我们有:

  addParams: { position: "last", rowID: '_empty', useDefValues: true, addRowParams: { url: '....', key: true, restoreAfterError: false, oneditfunc: function(rowId) { // display the save and cancel buttons $("#jSaveButton_" + rowId).show(); $("#jCancelButton_" + rowId).show(); }, // ... the rest },