UI Builder class
Today i will share how to give a filter lookup using an UI Builder class.
Today i will share how to give a filter lookup using an UI Builder class.
Step1 : First create a DP class for a customer report
SRSReportQueryAttribute(queryStr(BSCustTable)),
SRSReportParameterAttribute(classStr(SRCustomLookUpContract))
]
class SRCustomLookupDP extends SRSReportDataProviderBase
{
SRCustomLookUpContract contract;
CustNameTmp CustNameTmp;
AccountNum AccountNum;
CustGroupId CustGroupId;
}
private Query buildQuery(
Query _query,
AccountNum _AccountNum
)
{
if(_AccountNum)
_query.dataSourceTable(tablenum(CustTable), 1).addRange(fieldnum(CustTable, AccountNum)).value(queryvalue(_AccountNum));
return _query;
}
[
SRSReportDataSetAttribute('CustNameTmp')
]
public CustNameTmp getCustNameTmp()
{
select * from CustNameTmp;
return CustNameTmp;
}
private void getReportParameters()
{
SRCustomLookUpContract SRCustomLookUpContract = this.parmDataContract();
if (SRCustomLookUpContract)
{
AccountNum = SRCustomLookUpContract.parmAccountNum();
CustGroupId = SRCustomLookUpContract.parmCustGroup();
//AccountNum = SRCustomLookUpContract.parmAccountNum2();
}
}
public void insertCustNameTmp(AccountNum _accountNum)
{
CustTable CustTable;
;
while select CustTable where CustTable.AccountNum == _accountNum
{
CustNameTmp.AccountNum = _accountNum;
CustNameTmp.Name = CustTable.name();
CustNameTmp.insert();
}
}
/// <summary>
/// executes the logic based on the parameter entries
/// </summary>
/// <remarks>
/// fills up the temp table
/// </remarks>
[SysEntryPointAttribute]
public void processReport()
{
Query query;
QueryRun queryRun;
CustTable custTable;
;
this.getReportParameters();
queryRun = new QueryRun(this.buildQuery(this.parmQuery(),AccountNum));
while(queryRun.next())
{
custTable = queryRun.get(tableNum(custTable));
this.insertCustNameTmp(custTable.AccountNum);
}
}
Step2 : Second create a Contract class for a customer report
[DataContractAttribute,
SysOperationContractProcessingAttribute(classstr(SRCustomLookupsUIBuilder))
]
class SRCustomLookUpContract
{
AccountNum accountNum;
CustGroupId CustGroupId;
}
[DataMemberAttribute('AccountNum')
]
public AccountNum parmAccountNum(AccountNum _accountNum = accountNum)
{
accountNum = _accountNum;
return accountNum;
}
[DataMemberAttribute('CustGroup')
]
public CustGroupId parmCustGroup(CustGroupId _CustGroupId = CustGroupId)
{
CustGroupId = _CustGroupId;
return CustGroupId;
}
Step3 : Third create a UI Builder class for a customer report
class SRCustomLookupsUIBuilder extends SrsReportDataContractUIBuilder
{
DialogField dialogAccountNum,dialogCustGroup; //dialogCreditRating;
DialogGroup dialogGroup, dialogGroup2;
boolean enable;
}
private void accountNumLookup(FormStringControl accountNumLookup)
{
Query query = new Query();
QueryBuildDataSource qbds_CustTable;
SysTableLookup sysTableLookup;
QueryBuildRange qbr;
if (accountNumLookup != null)
{
// Create an instance of SysTableLookup with
// the current calling form control.
sysTableLookup = SysTableLookup::newParameters(tablenum(CustTable), accountNumLookup);
//sysTableLookup.addLookupMethod(
// Add fields to be shown in the lookup form.
qbds_CustTable = query.addDataSource(tableNum(CustTable));
sysTableLookup.addLookupfield(fieldnum(CustTable, CustGroup),true);
sysTableLookup.addLookupfield(fieldnum(CustTable, AccountNum), false);
qbr = qbds_CustTable.addRange(fieldNum(CustTable,CustGroup));
qbr.value("");
sysTableLookup.parmUseLookupValue(false);
sysTableLookup.parmQuery(query);
// Perform the lookup.
sysTableLookup.performFormLookup();
}
}
/// <summary>
/// Builds the dialog.
/// </summary>
/// <remarks>
/// The dialog appears with the parameters.
/// </remarks>
public void build()
{
SRCustomLookUpContract rdpContract = this.dataContractObject();
dialogAccountNum = this.addDialogField(methodstr(SRCustomLookUpContract,parmAccountNum),rdpContract);
dialogAccountNum.lookupButton(3);
dialogCustGroup = this.addDialogField(methodstr(SRCustomLookUpContract,parmCustGroup),rdpContract);
dialogAccountNum.lookupButton(2);
}
private void CustGroupLookup(FormStringControl CustGroupLookup)
{
Query query = new Query();
QueryBuildDataSource qbds_CustTable;
SysTableLookup sysTableLook;
QueryBuildRange qbr;
CustTable CustTable;
if (CustGroupLookup != null)
{
// Create an instance of SysTableLookup with
// the current calling form control.
sysTableLook = SysTableLookup::newParameters(tablenum(CustTable), CustGroupLookup);
//sysTableLookup.addLookupMethod(
// Add fields to be shown in the lookup form.
qbds_CustTable = query.addDataSource(tableNum(CustTable));
sysTableLook.addLookupfield(fieldnum(CustTable, CustGroup),false);
sysTableLook.addLookupfield(fieldnum(CustTable, AccountNum), true);
qbr = qbds_CustTable.addRange(fieldNum(CustTable,CustGroup));
qbr.value(dialogAccountNum.value());
sysTableLook.parmUseLookupValue(false);
sysTableLook.parmQuery(query);
// Perform the lookup.
sysTableLook.performFormLookup();
}
}
public boolean customerAccModified(FormStringControl _control)
{
dialogAccountNum.value(_control.valueStr());
return true;
}
public void postRun()
{
Dialog dialogLocal = this.dialog();
DialogField dialogField, dialogField1;
super();
// This method should be called in order to handle events on dialogs.
dialogLocal.dialogForm().formRun().controlMethodOverload(false);
// Override the methods of department field.
dialogField1 = this.bindInfo().getDialogField(this.dataContractObject(), methodstr(SRCustomLookUpContract, parmCustGroup));
dialogField1.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(SRCustomLookupsUIBuilder,CustGroupLookup), this);
dialogField = this.bindInfo().getDialogField(this.dataContractObject(), methodstr(SRCustomLookUpContract, parmAccountNum));
dialogField.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(SRCustomLookupsUIBuilder,accountNumLookup), this);
}