I'm doing some inline editing on the jqgrid. The client wants a confirmation dialog to appear that the user really wanted to save the changes made (similar to how delete works). In looking at http://github.com/tonytomov/jqGrid/blob/master/js/grid.inlinedit.js I've noticed that the editRow command takes these parameters.
table.jqGrid('editRow', id, true/keys/, function(){alert('1');}/oneditfunc/, function(){alert('1.5'); return false;}/successfunc/, null/url/, null/extraparam/, function(){alert('2');}/aftersave/, function(){alert('3');}/error/, function(){alert('4');}/afterrestore/);
when i start editing the oneditfunc gets called. after the post to the serve开发者_StackOverflowr successfunc get's called and then afterrestore gets called. It seems that there should be a beforeSave or something like that?
These parameters get used and sent to the saveRow function. It doesn't look like there is anywhere where I can inject a method to abort the sending of the data or popup a the modal window to confirm the changes being made.
Is this oversight on my part or is this some functionality that I'll have to bake into the jqgrid?
One way to solve your problem is to use custom validation editrules. Before the data will be send to the server it will be validated. The only disadvantage of the approach is that if the user decide not to send the data, the error message with the text which you mostly produce will be displayed.
Another way will be the usage of serializeRowData together with the errorfunc
(the parameter of the editRow
). Typically serializeRowData parameter of jqGrid will be used to modify or encode the data which will be send to the server. So if you display inside of the function a conformation dialog and send no data or a dummy wrong data to the server in the case, the server can answer with the known error. Then inside of your errorfunc
you can ignore this special error. So you can solve the problem with the error message. After all because of error jqGrid call "restoreRow" and the original data will be restored.
精彩评论