How to add "Enabled" and "Visible" Properties of a custom control


Badge +2

I am developing a custom control and written properties like Visible and Enabled in Definition.xml as shown below.

 

<Prop ID="IsVisible" friendlyname="Visible" type="bool" category="General" refreshdisplay="true"><Value>true</Value></Prop><Prop ID="IsEnabled" friendlyname="Enabled" type="bool" category="General" refreshdisplay="true"><Value>true</Value></Prop>

 

 

 ...and the code behind Control.cs goes like this:

public bool IsVisible{get { return this.GetOption<bool>("isvisible", true); }set { this.SetOption<bool>("isvisible", value, true); }}public bool IsEnabled{get { return this.GetOption<bool>("isenabled", true); }set { this.SetOption<bool>("isenabled", value, true); }}

in Control.js file, i have the get ans set methods written as below.

getProperty: function (objInfo) {if (objInfo.property.toLowerCase() == "value") {return Control.getValue(objInfo);}else {return $('#' + objInfo.CurrentControlId).data(objInfo.property);}},setProperty: function (objInfo) {switch (objInfo.property.toLowerCase()) {case "width":Control.setWidth(objInfo.Value);break;case "height":Control.setHeight(objInfo.Value);break;case "style":Control.setStyles(null, objInfo.Value, $('#' + objInfo.CurrentControlId));break;case "value":Control.setValue(objInfo);break;case "isvisible":Control.setIsVisible(objInfo);break;case "isenabled":Control.setIsEnabled(objInfo);break;default:$('#' + objInfo.CurrentControlId).data(objInfo.property).value = objInfo.Value; //set default property}},

The control is showing fine with default options like Visible and Enabled Checked. The issue is when i change the state of those, nothing is happening. Where am i going wrong? How to make these properties work as like normal controls?

 


2 replies

Badge +9

Hi Yeshwanth,


 


Let me attach a document i have on creating a custom control.


Please see if the information in the document is helpful.


 


-Jean

Badge +2
Hi Jean,

Thank you for sharing the document. I will go through it and let you know. I really appreciate the help!!

~Yeshwanth

Reply