In my situation, I have to allow users to edit various cells in the grid, and then save the entire grid to the server later. I pretty much solved this problem with inline editing and saving in clientArray. However, I am trying to use editRules and ran into some problems.
If I create an editable column and use edit rules to require its number
{ name: 'Value', index: 'Value', width: 50, sortable: true,edittype: 'text', editable: true, editoptions: { maxlength: 10 }, editrules:{number: true}, formatter:currencyFmatter, unformat:unformatCurrency },
and I control editing and saving in the onSelectRow event:
onSelectRow: function(id){ if(id && id!==lastSel){ jQuery("#Groups").saveRow(lastSel,true,'clientArray'); jQuery("#Groups").editRow(id,true); } lastSel=id },
Then I use the button click event to save the grid. Everything works fine until I add a numerical value to the Value cell, and then click on the line below. He throws a warning and stops saving, but that does not stop me from changing lines. Therefore, I now have two lines for editing. Is there a way to catch an editrule error so that I can handle it before moving on to the next line.
I tried using functions with saveRow (succesfunc, aftersavefunc, errorfunc, afterrestorefunc), of which everyone says that fire after saving data to a server, which does not seem to work for 'clientArray.
Basically, I need to find a way to verify the data in the built-in editing while saving the information, sentences, and, in particular, the examples will be highly appreciated in the clientArray.
Thanks.
After a long game, I decided that the editing rules did not work so well with InLine Editing. So, as you suggested, I made my own verification procedure. The trick was to figure out how to get the value of the edited row.
The only thing I'm trying to understand now is how to get focus in order to return to the Value column. Go back to the documentation!
if(id && id!==lastSel){ //dont save if first click if (lastSel != -1) { //get val of Value to check var chkval = jQuery("#"+lastSel+"_Value").val() ; // verify it is a number if (isNaN(chkval)) {//If not a number //Send Validation message here //Restore saved row jQuery("#Grid").restoreRow(lastSel); //Return to failed save row jQuery("#Grid ").setSelection(lastSel,false); //reopen for editing jQuery("#Grid ").editRow(lastSel,true); //Note - dont reset lastSel as you want to stay here } else { // If number is good, proceed to save and edit next jQuery("#Grid ").jqGrid('saveRow',lastSel, checksave, 'clientArray', {}, null, myerrorfunc); jQuery("#Grid ").editRow(id,true); lastSel=id; }; isDirty = true; }; else { //first click - open row for editing alert("new Edit") jQuery("#Grid ").editRow(id,true); lastSel=id;} }