There’s a problem with the ComboBox control in the Infor CRM (Saleslogix) Web Client. It won’t disable. Sure, it has an Enable property, but setting it to false has no effect on the control and it will remain enabled. However, there is a solution. Luckily, the control itself renders as a Dijit Select form widget from the Dojo UI Library so we can simply manipulate the control based on what can be done to the Dijit Select.
As I mentioned earlier, the problem is that setting the ComboBox control’s Enabled property to false does not disable the control. You’ll still end up with the control looking, and worse, behaving as an enabled control (allowing the user to still interact with it).
That’s no good if you want to ensure the user can only access the control if you intend that behavior.
The ComboBox control itself actually gets added to the deployed SmartPart as an ASP.NET ListBox with a specific Dojo attribute. It will look like this on the page:
<asp:ListBox runat="server" ID="comboBox1" data-dojo-type="dijit.form.Select" SelectionMode="Single" Rows="1" CssClass="select-control"> </asp:ListBox>
The magic here is the data-dojo-type=”dijit.form.Select” part. At runtime, the Dojo Dijit library does it’s work and changes that to a nice looking Dijit Select dropdown control, AKA the Inform CRM ComboBox. Knowing this, we can manipulate the control as a Dijit Select widget. The Dijit Select widget can be disabled by adding a “disabled” attribute with a value of “disabled” (yep, disabled=”disabled”).
So, to disable the ComboBox in a code snippet, in place of doing this:
comboBox1.Enabled = false;
We can do this:
// disable the combobox comboBox1.Attributes["disabled"] = "disabled";
This will disable the ComboBox just as you’d expect it to be. Users cannot interact with it and it looks disabled.
Then to enable the ComboBox:
// enable the combobox comboBox1.Attributes["disabled"] = "false";
Just as easy as using the Enable property, but the big difference is that it works 🙂