I am playing with jqGrid and I have a combination of both a pager (with View and Refresh) and an inlineNav (with Add, Edit, Save, Cancel).
I have toppager:true and cloneToTop:true which places the pager controls, both at top and bottom. However I can't seem to do the same with my inlineNav.
Full code follows, but I tried to do the following, but the top buttons do not respond properly and it's a bit of a mess:
$("#pager_left").clone().appendTo("#list_toppager_left");
Can anyone help?
$(document).ready(function() {
var lastSel;
$("#list").jqGrid({
url:'db.php',
datatype: 'json',
mtype: 'GET',
colNames:[
/*...*/
],
colModel :[
/*...*/
],
pager: '#pager',
autowidth:true,
height: "100%",
rowNum:20,
rowList:[20,50,100,1000],
loadtext: 'Loading...',
viewrecords: true,
sortname:'BUSINESS',
sortorder:"ASC",
multiselect:false,
sortable:true,
toppager:true,
ignorecase:true,
gridview: true,
editurl:"db_edit.php",
caption: 'Bath BID',
onSelectRow: function(id) {
if(id && id!==lastSel){
$('#list').saveRow(lastSel);
lastSel=id;
}
}
}).navGrid('#pager', {
edit:false,
add:false,
del:true,
view:true,
search:false,
viewtext:"View",
closeOnEscape:true,
edittext:"Edit",
refreshtext:"Refresh",
addtext:"Add",
deltext:"Delete",
searchtext:"Search",
cloneToTop:true},{},{},{},{multipleSearch:true});
$("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : true});
$("#list").jqGrid('inlineNav','#pager', {
edittext:"Edit",
addtext:"Add",
savetext:"Save",
canceltext:"Cancel",
cloneToTop:true
});
Thanks in advance!
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.
I analysed your problem. First of all the option
cloneToTop: true
is supported by navGrid, but not by inlineNav. Moreover the ids of the buttons of will be constructed using the grid id as the prefix. As the result one will haveas ids. On the other side the ids of the standard navGrid buttons from will have the following ids after
cloneToTop: true
:So one can't just call
navGrid
twice with both pager:One will receive as the results id duplicates (see the demo).
Making manual id modifications before calling the
inlineNav
at the second time will also not really help (see the next demo) because the code which will be executed after clicking on the inline buttons use the same rules of id building. So only the buttons having original ids will be disabled or enabled.I can summarize: the current implementation of
inlineNav
don't support the top pager. I would recommend you useinlineNav
only once. If you need to have the icons in the second pager you should better examine the source code ofinlineNav
(see here for example) and add in the same way new buttons with respect ofnavButtonAdd
and using another ids.I hope that in the next version the code of
inlineNav
will be extended to support two pager at the same time.UPDATED: I forgot to mention, that I fixed a little position of the text relative to icons in the navigator bars. It is not the main subject of your question, but probably it will be interesting for you too: