Disable and Enable dropdown on change of another field

By

243 views

 

I had to disable and enable a dropdown on check/uncheck of a checkbox field in Sugar 7. I did the following customizations to accomplish the task:

    • First we will need to extend and override record view controller. Record view can be extended following the guidelines in Extending Sugar7 Record View.

custom/modules/<module>/clients/base/views/record/record.js

  • Then in controller file we would need to bind an event on change of checkbox. Place the following code in initialize function
this.model.on("change:my_checkbox", this.DisableEnableDropdown, this);
  • Disable and EnableDropDown function

     

DisableEnableDropDown: function () {
  if(this.model.get('my_checkbox') != '1')
  {
      $("[data-fieldname=mydropdown] input").select2('disable');
  }
  else
  {
         $("[data-fieldname=mydropdown] input").select2('enable');
  }
}

Once the files are in place, you will need to navigate to Admin > Repair > Quick Repair and Rebuild.

Need Help? Get Free Consultation


Please leave this field empty.

Get in touch



Please leave this field empty.

CONTACT INFORMATION