Tuesday, 24 April 2018

SSRS : Enable/ Disable contract class Control Based on other contract parameter control


In this blog we will see how to enable / disable contract class parameter control based on the modification of other contract class parameter. This all is going to be happened in UI Builder class
So here we go
1.       First write the Method which is responsible to perform actual functions like enabling and disabling control
In this blog I will be using Enum Control and based on its modification disabling lookup controls
Where in below image Report Type is Enum Control and WindMast and Sensor are the lookup controls


Enable/ Disable Method should be written in UI Builder class will be like

private boolean EnableControls(FormComboBoxControl _control)
{
   
   
    if(_control.valueStr() == enum2str(TK_TurbineSummary::Production))
    {
    dWindMast.enabled(false);
    dSensor.enabled(false);
    }
    else
    {
       dWindMast.enabled(true);
    dSensor.enabled(true);

    }
    return true;
}

In above piece of code I have disable the lookup controls On “Production” Report Type and make them enable on Wind Speed Report Type


Where dWindMast and dSensors are the dialog field define in Build method of UI Class like Below



Now In Post Build Method of UI Class we need to register our above created method “EnableControls”  Like below

public void postBuild()
{

 dReportType = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(TK_TurbineSummaryContract, parmReportType));
            dReportType.registerOverrideMethod(methodStr(FormComboBoxControl, modified), methodStr(TK_TurbineSummaryUI, EnableControls), this);
            dShowProduction = this.bindInfo().getDialogField(this.dataContractObject(), methodStr(TK_TurbineSummaryContract, parmShowProduction));
}

When we Run Report and change the Report type Drop down value Result will be as below
Disable Controls :


Enabling Control on drop down selection changed

That is how we can enable/ disable controls. 
Last but not the least Happy daxing :)  



No comments:

Post a Comment