It's a little bit clunky, but for a quick win I just duplicated the code within grid.inlinedit.js in order to recreate buttons that do the same thing in both top and bottom bars... it seems to work.
if(o.add) {
$($t).jqGrid('navButtonAdd', elem,{
caption : o.addtext,
title : o.addtitle,
buttonicon : o.addicon,
id : $t.p.id+"_iladd",
onClickButton : function ( e ) {
$($t).jqGrid('addRow', o.addParams);
if(!o.addParams.useFormatter) {
$("#"+$t.p.id+"_top_ilsave").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilcancel").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iladd").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iledit").addClass('ui-state-disabled');
$("#"+$t.p.id+"_ilsave").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_ilcancel").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_iladd").addClass('ui-state-disabled');
$("#"+$t.p.id+"_iledit").addClass('ui-state-disabled');
}
}
});
$($t).jqGrid('navButtonAdd', '#' + $($t)[0].id + '_toppager_left',{
caption : o.addtext,
title : o.addtitle,
buttonicon : o.addicon,
id : $t.p.id+"_top_iladd",
onClickButton : function ( e ) {
$($t).jqGrid('addRow', o.addParams);
if(!o.addParams.useFormatter) {
$("#"+$t.p.id+"_top_ilsave").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilcancel").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iladd").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iledit").addClass('ui-state-disabled');
$("#"+$t.p.id+"_ilsave").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_ilcancel").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_iladd").addClass('ui-state-disabled');
$("#"+$t.p.id+"_iledit").addClass('ui-state-disabled');
}
}
});
}
if(o.edit) {
$($t).jqGrid('navButtonAdd', elem,{
caption : o.edittext,
title : o.edittitle,
buttonicon : o.editicon,
id : $t.p.id+"_iledit",
onClickButton : function ( e ) {
var sr = $($t).jqGrid('getGridParam','selrow');
if(sr) {
$($t).jqGrid('editRow', sr, o.editParams);
$("#"+$t.p.id+"_ilsave").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_ilcancel").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_iladd").addClass('ui-state-disabled');
$("#"+$t.p.id+"_iledit").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilsave").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilcancel").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iladd").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iledit").addClass('ui-state-disabled');
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+$t.p.id,jqm:true});$("#jqg_alrt").focus();
}
}
});
$($t).jqGrid('navButtonAdd', '#' + $($t)[0].id + '_toppager_left',{
caption : o.edittext,
title : o.edittitle,
buttonicon : o.editicon,
id : $t.p.id+"_top_iledit",
onClickButton : function ( e ) {
var sr = $($t).jqGrid('getGridParam','selrow');
if(sr) {
$($t).jqGrid('editRow', sr, o.editParams);
$("#"+$t.p.id+"_ilsave").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_ilcancel").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_iladd").addClass('ui-state-disabled');
$("#"+$t.p.id+"_iledit").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilsave").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilcancel").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iladd").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iledit").addClass('ui-state-disabled');
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+$t.p.id,jqm:true});$("#jqg_alrt").focus();
}
}
});
}
if(o.save) {
$($t).jqGrid('navButtonAdd', elem,{
caption : o.savetext || '',
title : o.savetitle || 'Save row',
buttonicon : o.saveicon,
id : $t.p.id+"_ilsave",
onClickButton : function ( e ) {
var sr = $($t).jqGrid('getGridParam','selrow');
if(sr) {
if($("#"+$.jgrid.jqID(sr), "#"+$.jgrid.jqID($t.p.id) ).hasClass("jqgrid-new-row")) {
var opers = $t.p.prmNames,
oper = opers.oper;
if(!o.editParams.extraparam) {
o.editParams.extraparam = {};
}
o.editParams.extraparam[oper] = opers.addoper;
}
$($t).jqGrid('saveRow', sr, o.editParams);
$("#"+$t.p.id+"_ilsave").addClass('ui-state-disabled');
$("#"+$t.p.id+"_ilcancel").addClass('ui-state-disabled');
$("#"+$t.p.id+"_iladd").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_iledit").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilsave").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilcancel").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iladd").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iledit").removeClass('ui-state-disabled');
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+$t.p.id,jqm:true});$("#jqg_alrt").focus();
}
}
});
$("#"+$t.p.id+"_ilsave").addClass('ui-state-disabled');
$($t).jqGrid('navButtonAdd', '#' + $($t)[0].id + '_toppager_left',{
caption : o.savetext || '',
title : o.savetitle || 'Save row',
buttonicon : o.saveicon,
id : $t.p.id+"_top_ilsave",
onClickButton : function ( e ) {
var sr = $($t).jqGrid('getGridParam','selrow');
if(sr) {
if($("#"+$.jgrid.jqID(sr), "#"+$.jgrid.jqID($t.p.id) ).hasClass("jqgrid-new-row")) {
var opers = $t.p.prmNames,
oper = opers.oper;
if(!o.editParams.extraparam) {
o.editParams.extraparam = {};
}
o.editParams.extraparam[oper] = opers.addoper;
}
$($t).jqGrid('saveRow', sr, o.editParams);
$("#"+$t.p.id+"_ilsave").addClass('ui-state-disabled');
$("#"+$t.p.id+"_ilcancel").addClass('ui-state-disabled');
$("#"+$t.p.id+"_iladd").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_iledit").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilsave").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilcancel").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iladd").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iledit").removeClass('ui-state-disabled');
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+$t.p.id,jqm:true});$("#jqg_alrt").focus();
}
}
});
$("#"+$t.p.id+"_top_ilsave").addClass('ui-state-disabled');
}
if(o.cancel) {
$($t).jqGrid('navButtonAdd', elem,{
caption : o.canceltext || '',
title : o.canceltitle || 'Cancel row editing',
buttonicon : o.cancelicon,
id : $t.p.id+"_ilcancel",
onClickButton : function ( e ) {
var sr = $($t).jqGrid('getGridParam','selrow');
if(sr) {
$($t).jqGrid('restoreRow', sr, o.editParams);
$("#"+$t.p.id+"_ilsave").addClass('ui-state-disabled');
$("#"+$t.p.id+"_ilcancel").addClass('ui-state-disabled');
$("#"+$t.p.id+"_iladd").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_iledit").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilsave").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilcancel").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iladd").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iledit").removeClass('ui-state-disabled');
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+$t.p.id,jqm:true});$("#jqg_alrt").focus();
}
}
});
$("#"+$t.p.id+"_ilcancel").addClass('ui-state-disabled');
$($t).jqGrid('navButtonAdd', '#' + $($t)[0].id + '_toppager_left',{
caption : o.canceltext || '',
title : o.canceltitle || 'Cancel row editing',
buttonicon : o.cancelicon,
id : $t.p.id+"_top_ilcancel",
onClickButton : function ( e ) {
var sr = $($t).jqGrid('getGridParam','selrow');
if(sr) {
$($t).jqGrid('restoreRow', sr, o.editParams);
$("#"+$t.p.id+"_ilsave").addClass('ui-state-disabled');
$("#"+$t.p.id+"_ilcancel").addClass('ui-state-disabled');
$("#"+$t.p.id+"_iladd").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_iledit").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilsave").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_ilcancel").addClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iladd").removeClass('ui-state-disabled');
$("#"+$t.p.id+"_top_iledit").removeClass('ui-state-disabled');
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+$t.p.id,jqm:true});$("#jqg_alrt").focus();
}
}
});
$("#"+$t.p.id+"_top_ilcancel").addClass('ui-state-disabled');
}
'#' + $($t)[0].id + '_toppager_left'
. There are already parameterelem
. I would add buttons only in theelem
pager, but I would use ids constructed from theid
of theelem
. Moreover I would use additional classes toiladd
,iledit
and so on buttons then the code for disabling or enabling of the buttons can be shorter. I would also to use a little another rules how to construct the ids of the buttons to have no possible conflicts with buttons added byinlineNav
. – Crossgrained