0

I'm trying to use inline editing in a grid, save/edit/cancel/delete buttons are custom, I have several validation functions for every column that need to be called before saving, I'm making a function that will be called on pressing enter on the row, however I can't seem to be able to stop it from saving even tho I return false on successfunc.

$grid.editRow(id,{
    keys : true,
    successfunc : function(data){
        saveData(data);
        return [false,""];       
    }
});

PS: editrules defined on each column won't help me because I want my validations to be called only on save

cosmin.danisor
  • 943
  • 1
  • 12
  • 29

1 Answers1

1

I think you are a little to late in your validation in this case.

From: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing

succesfunc: if defined, this function is called immediately after the request is successful. This function is passed the data returned from the server. Depending on the data from server; this function should return true or false.

Are you validating before you let the Save occur?

Mark
  • 3,123
  • 4
  • 20
  • 31
  • That's what I'm trying, I only chose successfunc because I don't know any other function that gets called before, I'm not sure if in extraparams I can set a validation function i can't seem to be able to find an example anywhere – cosmin.danisor Mar 12 '13 at 15:40
  • I'm confused, if you have you own custom buttons, can't you hook in your validation there before you pass off to the server? – Mark Mar 12 '13 at 15:55
  • I already did, that works fine. Now I'm trying to validate on pressing Enter on the row. As far as you know is the any way of doing that other than setting an keydown event on the tr? – cosmin.danisor Mar 12 '13 at 15:58
  • Did you look at integrating your validation into jqGrid via http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3acommon_rules#editrules which would do your validation on an enter. Other then that you could get into the Ajax event but I think you are making yourself work there, so after that bind to the enter key on the row. Probably the best though is to build the validation into jqGrid. – Mark Mar 12 '13 at 16:08
  • I'll just use keys:false and add an keydown event on the tr[editable=1], this is the easiest way i think. Thanks for your help – cosmin.danisor Mar 12 '13 at 16:10