1

I have a jqGrid table and it works well. I use Spring and communicate everything via REST. I want to add adding row ability to my jqGrid. However I don't want to use default button of the jqGrid. These are my variables for adding a new record:

userName
password
mail
admin

When a user click a button on my page, a popup appears and there writes that field names. I want when user clicks add button at that popup page, a new user should be added to jqGrid and new data should be send to the server of course(to REST URL.)

How can I do that?

kamaci
  • 72,915
  • 69
  • 228
  • 366

1 Answers1

0

You can use addfunc to implement you custom behavior of the Add button. In the case you will have to do almost all work yourself. You should send the data to the server yourself with respect of jQuery.ajax for example and reload the grid after it or add the new row to the grid with respect of addRowData.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Is there any example for addfunc? – kamaci Sep 19 '11 at 12:53
  • @kamaci: Look at [here](http://stackoverflow.com/questions/2841794/preventing-the-opening-of-a-form-on-a-add-button-click/2841899#2841899) for example. In general it's just a function which are called at the click on the "Add" button. – Oleg Sep 19 '11 at 13:02
  • Thanks for your answer however I don't want to customize jqGrid's add button, in fact it will not be visible for users. I want to write my own add function that can be accessible from another button that I generated on my page. – kamaci Sep 19 '11 at 13:07
  • @kamaci: If you want just add the row to the grid you should use `addRowData`. If I understand you correct all other things you want implement yourself. – Oleg Sep 19 '11 at 13:21
  • thanks for your responses. I send new row to the server successfully. There are two choices right now. I can refresh the table or add new row to table. How can I do them? – kamaci Sep 21 '11 at 07:17
  • @kamaci: To add the row to table you can use [addRowData](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods) method. The problem is to add the row so that the sorting of the grid stay correct. So one reload the grid typically: `$('#list').trigger('reloadGrid')`. See [here](http://stackoverflow.com/questions/3807623/jqgrid-paging-question/3808014#3808014) for more information about optional parameters of `reloadGrid`. – Oleg Sep 21 '11 at 07:31