Search code examples
jqueryjqgrid

Remove editable property of a cell based on other sell value in the same row


JQGrid

I have a JQGrid as shown in the image below. I want, if user enter value in Step Up column, Value of Step Down will be 0 and Step Down column will become non editable. So that user can not enter value in Step Down column.

Same should be true for Step Down column also. ie, if user enters value in Step Down column, Step Up Column will become non editable.

I was trying to achieve this using below code in column's edit options but not with much success:

 { name: 'stepup', index: 'stepup', align: 'center', width: 250, 
  sortable: false, editable: true,  
   editoptions:{dataEvents:[{type: 'change', 
       fn: function(e){
          var setpup_val = $(this).val();
          if($.trim(setpup_val)!=""){
              $(this).jqGrid('setColProp', 'stepdown', {editable:false});
          }
        }
   }]}},

PS: I am using free-jqgrid/4.15.2


Solution

  • You use currently Boolean value of editable property: editable: true. Free jqGrid supports callback function instead. I described the possibility in the wiki article. It seems to me that you would easy implement your requirement using the feature.