There is a textbox control in one column in my jqgrid. When value is entered in this textbox in a row , it should compare that value from another column (which is non editable) and show error when the values are not equal.
Asked
Active
Viewed 858 times
1
-
Is your question about inline edit or form edit? Can you add more context to your question and a sample code or jsfiddle link. – Helen Araya May 04 '16 at 14:08
-
This is for inline edit for jqgrid. I edit one column in jqgrid on cell click and i want to make sure that the value i enter is not greater than some other column value. – SunilA May 05 '16 at 06:09
-
Much similar http://stackoverflow.com/questions/30645088/jqgrid-change-values-of-editable-cell-on-change-of-another-cell-dependent-colum – Dipen Shah May 05 '16 at 16:22
-
@DipenShah Yes it is similar this one is on cell edit not on a row edit and also returning false on beforeSelectRow does not save the row however returning false on beforeSaveCell saves the cell(when it shouldn't) that's why the Solution is different and uses custom formatter. – Helen Araya May 05 '16 at 19:02
-
@SunilA please accept the answer if it works for you. Thanks! – Helen Araya May 05 '16 at 19:05
-
Can u give me the code snippet for the validation func. Also i have one more issue in this : when the value entered is not required, the column should show the previous value. I show a textbox on cell edit click and the previous value is always coming as 0. how to get the previous value of the column. – SunilA May 05 '16 at 19:20
1 Answers
1
From the wiki in Here
You can see the solution I created in JsFiddle
To see it working try to edit lastname cell and it will throw an error if it does not match firstname in the row (unrealistic but just for illustration purposes)
Use beforeSaveCell
afterSaveCell: function(rowid,name,val,iRow,iCol) {
alert("alert1!");
},
beforeSaveCell: function(rowid,name,val,iRow,iCol) {
// Just to get the current row b/se it is not available in custom_func
currentRow= rowid;
},
AND add editrules to your cell to be edited and validated
{name:'lastname', index:'lastname', width:90, editable: true , "editrules":{"custom":true,"custom_func":validateText}},

Helen Araya
- 1,886
- 3
- 28
- 54