SunilA
SunilA

Reputation: 583

Jqgrid - Compare value of two columns in jqgrid. One of them is a textbox and other is non editable column.

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.

Upvotes: 1

Views: 919

Answers (1)

Helen Araya
Helen Araya

Reputation: 1946

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}},

Upvotes: 1

Related Questions