This blog demonstrates how to use the registerOverride()
method in the UIBuilder
class to dynamically enable or disable dialog fields, such as date ranges, based on user input.
class myUIBuilder extends SrsReportDataContractUIBuilder
{
DialogField dlgIsManually;
DialogField dlgFromDate;
DialogField dlgToDate;
myContract contract;
public void postBuild()
{
super();
contract = this.dataContractObject() as myContract;
dlgfromdate = this.bindinfo().getdialogfield(contract,
methodstr(myContract,parmFromDate));
dlgtodate this.bindinfo().getdialogfield(contract,methodstr
(myContract,parmToDate));
dlgIsManually = this.bindInfo().getDialogField(contract,methodStr (myContract,parmIsManually));
//By default these controls will be disabled when parameter form loads first time
dlgFromDate.enabled(false);
dlgToDate.enabled(false);
if (dlgIsManually.value() == NoYes::Yes)
{
dlgFromDate.enabled(true);
dlgToDate.enabled(true);
}
//disableDataRange() method attached with modified event of dlgIsManually control so //this will call whenever dlgIsManually is modified
dlgIsManually.registerOverrideMethod(methodstr(
FormCheckBoxControl,modified), methodstr(myUIBuilder, disableDateRange),this);
}
/// Disables date range based on checkbox selection
public boolean disableDateRange(FormCheckBoxControl _isManually)
{
boolean returnValue;
returnValue = _isManually.modified();
dlgFromDate.enabled(true);
dlgToDate.enabled(true);
if (returnValue && dlgIsManually.value() == NoYes::No)
{
dlgFromDate.enabled(false);
dlgToDate.enabled(false);
}
return returnValue;
}
}
UIBuilder provides a powerful way to customize and control parameters by manipulating dialog fields at runtime.
By using the registerOverride()
method in UIBuilder, you can control the behavior of dialog fields in a parameter form dynamically.