Tuesday, August 9, 2016

Apex Tabular Form -- disable one column based on value of another column

Apex Tabular Form -- disable one column based on value of another column


I have a Tabular Form, one col is an LOV(Phone MMS provider), another col is a text field, I would like to disable that text column if user doesn't choose "Other" in the LOV, otherwise make it enterable. 

Here is how to do it:

1. create a dynamic action:
    Event: Change on JQuery selector:  select[name='f08'] --- here f08 is the LOV field
    execute javascripts:
      var lov = this.triggeringElement.id;
      var row = lov.split("_")[1];
      if ($lov(el)  == "Other") {
      // disable the field 
       //       $x_disableItem("f09_" + row, false);  --- change this to below line, because I got no data found issue with this line after I added more than 16 rows in the tabular table, not sure the reason but changed it to below fixed the issue
              $( "#f09_" + row ).prop( 'readOnly', false);
      }
      else {
     // enable the field
     //        $x_disableItem("f09_" + row, true); ---- Change this to below line
             $( "#f09_" + row ).prop( 'readOnly', true);
      };

 --- f09 is the text field in the tabular form
2. copy the dynamic action, change the event to "Page Load"

No comments:

Post a Comment