free-jqgrid / jqGrid

jQuery grid plugin
https://github.com/free-jqgrid/jqGrid
Other
480 stars 196 forks source link

Add button to toolbar #422

Closed emeaaa closed 6 years ago

emeaaa commented 6 years ago

Hi,

i'm trying to add a series of buttons( see https://jsfiddle.net/bozzoa/mm33jy7e/20/ for a quick example) by building and inserting them after the creation of the jqGrid.

The issue I'm having is that I'm not sure about where to call the function that creates the buttons, because it must be called after the complete creation of the grid or it will fail.

I'm trying to use the event loadComplete but with bigger grids often I experience that the function is called before the navigation toolbar is completed and so the buttons can't be added. Is there another event that is called last?

Thank you

OlegKi commented 6 years ago

You try to create and insert the buttons manually instead of usage standard jqGrid methods. I recommend you to use navGrid and navButtonAdd methods instead. See old documentation here [here] and (http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons) and the wiki article, which describes some enhancements implemented in free jqGrid. You try to resize the size of columns based on the width of content. The feature exist too in free jqGrid. See the wiki article. In all cases you should take in consideration that the outer part of grid will be created once. One creates the pager and navigator bar once too. On the other side loadComplete will be called every time on sorting, paging, filtering. Thus loadComplete is mostly not good for placing of buttons in the outer part of the grid.