0

I has a jqgrid and I need a delete column where each row has a delete button, but the problem is that I need to delete the row only on localdata because I don't need to go to the server but I did not know how to do this on local data only?

Wilmer
  • 53
  • 1
  • 10
  • It's important to know **which version of jqGrid you use?** Local form editing (and local delete form) are included in jqGrid 4.7. It's possible to implement local delete in old version of jqGrid, but the code will be longer. – Oleg Apr 16 '15 at 09:59
  • hola, tengo la versión jqGrid 4.5.1, pero puedo usar una versión más reciente if that is better – Wilmer Apr 16 '15 at 19:59
  • hi, I has the jqGrid 4.5.1, version, but I can use a newer version if that is better, please I would like how to do local delete form in gqgrid 4.7? – Wilmer Apr 16 '15 at 23:16
  • I wrote in my answer that the usage of `editurl: "clientArray"` parameter of jqGrid would be enough for implementing local delete in jqGrid 4.7 or higher or for free jqGrid. – Oleg Apr 17 '15 at 04:52
  • hi tony, thanks for the response, that works, I have another question, I have lines of the invoice in the jqgrid and I need to sum the total column when the user add or delete lines, Is there any method or event to do this sum? – Wilmer Apr 17 '15 at 17:48

1 Answers1

0

Look at the old answer where I described an implementation of local delete at the first time. The later answers: this one and this one contained the code for more recent version of jqGrid and for other parts of form editing.

Staring with jqGrid 4.7 one need do nothing. The usage of editurl: "clientArray" is the only which one need to do.

To implement "Delete" button in every row of the grid you can use formatter: "actions" in an additional column. By default it adds Edit and Delete buttons using editbutton: false in formatoptions of the column you can remove Edit button. In the way you will have only Delete button like you want. delOptions property of formatoptions allows you to customize the options of delGridRow called on click on the Delete button.

The version 4.5.1 is really old. So I recommend you to consider to upgrade to more recent version of free jqGrid which you can download from github. Additionally with possibility of local editing/deleting you will get some performance improvements and many new features. See the readme and wiki for more details. Some from the demos included at the end of readme uses local editing with respect of formatter: "actions". So you can reduce the demos to your requirements.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • hi tony, thanks for the response, that works, I hava another question, I have a lines of the invoice in the jqgrid and I need to sum the total column when the user add or delete lines, Is there any method or event to do this sum? – Wilmer Apr 17 '15 at 17:47
  • I am making the sum after add a new line, but the problem for me is after delete a line because there is not a event for this, so I try to delete the line from my own button out the grid, but the problem is that I dont have way to get the event onclick when the user do click on the button of the message 'Delete selected record(s)?', how I can get a event to deduct the total after the user delete the line? – Wilmer Apr 17 '15 at 18:08
  • @Wilmer: My name is **Oleg**, not Tony. The best way to calculate the sum by column depend on other options of jqGrid which you use. You can start with the usage of method [getCol](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:methods) with the corresponding parameters. You can use callbacks of [delGridRow](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing#delgridrow) like `afterComplete` to do some actions after the row is deleted. You should start to post the code which you use. It simplify understanding what you do and I can answer you more exactly. – Oleg Apr 17 '15 at 18:48
  • thanks Oleg, I just put my code in this question http://stackoverflow.com/questions/29709294/jqgrid-what-is-the-best-way-to-sum-the-values-of-a-specific-column. – Wilmer Apr 17 '15 at 21:05