4

I want to add three buttons on top of the grid for add,edit,delete. And want to make calls to separate URLs for each of the operation.I want to use Form Editing for this. Can anyone suggest me a sample code for this.

Thanks in advance, Abhishek

user1516871
  • 161
  • 1
  • 2
  • 10

1 Answers1

5

If you need to add form editing buttons on top of the grid you should use toppager:true option of jqGrid. You don't need to define any other pager div and don't need to use pager option. jqGrid creates a new div for the pager itself. The id of the pager div will be constructed from the id of the grid and the "_toppager" suffix. For example if you use

<table id="grid"></table>

then the div of the pager will have the id="grid_toppager" and you can use

$("#grid").jqGrid("navGrid", "#grid_toppager", {/*navGrid options*/},
    {url: "yourEditUrl"}, {url: "yourAddUrl"}, {url: "yourDelUrl"});

I recommend you to read this and this old answers for additional information.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • If I want to change the position of the Add , Update and Delete icons then how can I do that ? – Bhavik Ambani Jul 31 '12 at 11:30
  • 1
    Hi Oleg one clarification,on click of add i need to open a new window/page instead of showing add pop up. – user1516871 Aug 13 '12 at 11:48
  • @user1516871: In the case you can use `{add:false,edit:false,del:false}` as `{/*navGrid options*/}` options. You can add your custom buttons with respect of `navButtonAdd`. To get the custom selected row see [the answer](http://stackoverflow.com/a/3024278/315935). To open new window you can set `window.location` explicitly like in [the answer](http://stackoverflow.com/a/5287994/315935) or [here](http://stackoverflow.com/a/3024278/315935). – Oleg Aug 13 '12 at 15:45