问题描述
我正在使用jqgrid的inlineNav选项向工具栏添加添加选项。我还使用动作格式化程序进行编辑和删除。
当我添加新行时,新添加的行有一个编辑图标和一个取消图标,而保存图标位于添加旁边的工具栏上。
I am using the inlineNav option of jqgrid to add a 'add' option to the toolbar. I am also using a actions formatter for edit and delete.When I add a new row, the newly added row has an edit icon and a cancel icon, whereas the save icon is on the toolbar next to the add.
有没有办法指定新添加的行有一个保存和取消图标而不是编辑图标?
Is there a way to specify that the newly added row have a save and cancel icon instead of having the edit icon?
推荐答案
如果有人有类似的问题。
In case anyone has a similar question.
我最终滚动了自己的格式化程序。
I ended up rolling my own formatter.
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 = "<div title='"+$.jgrid.edit.bSubmit+"' style='float:left;' class='ui-pg-div ui-inline-save' "+ocl+"><span class='ui-icon ui-icon-disk'></span></div>";
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 += "<div title='"+$.jgrid.edit.bCancel+"' style='float:left;margin-left:5px;' class='ui-pg-div ui-inline-cancel' "+ocl+"><span class='ui-icon ui-icon-cancel'></span></div>";
return "<div style='margin-left:8px;'>" + str + "</div>";
}else{
return $.fn.fmatter.actions(cellvalue, options, rowObject);
}
}
isSavedRow在由于添加了行而保存行后再次调用格式化程序的情况。我还将rowId默认为0.
默认操作传递false。
我将标记保存并从github上的源代码中取消4.5版
isSavedRow is passed as true in the case of the formatter being called again after a row has been saved due to being added. I also default the rowId to 0.Pass false for default operation.I took the markup for save and cancel from the source available on github for version 4.5
用法:
formatter: function(cellvalue,options,rowObject) {
return inlineNavAction(cellvalue,options,rowObject, (options.rowId!='new_row'));
}
new_row in
The new_row in
(options.rowId!='new_row')
是您为添加的行设置的默认rowId。 new_row是默认值。
is whatever you have set as the default rowId for an added row. new_row is the default.
这篇关于jqgrid inlineNav add - 在添加的行上显示保存图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!