Wednesday 7 June 2017

lookup in ssrs reports

lookup can be achieved by using UI Builder class

class PMWorkorderUIBuilder extends SrsReportDataContractUIBuilder
{
        WorkorderContract         contract; // Contract class
}

override the build method  to get the dialog fields on the report dialog

public void build()
{
    contract = this.dataContractObject();
    this.addDialogField(methodStr(WorkorderContract         ,parmEmpType),contract);
    this.addDialogField(methodStr(WorkorderContract         ,parmFromDate),contract);
    this.addDialogField(methodStr(WorkorderContract         ,parmToDate),contract);
    //super();
}

New method to create Lookup for the field

private void lookupEmptype(FormStringControl    _formStringControl)
{
    Query query;
    QueryBuildDataSource datasource;
    SysTableLookup          sysTableLookup      = SysTableLookup::newParameters(tableNum(EmplMaintainance), _formStringControl);

    query = new Query();
    datasource = query.addDataSource(tableNum(EmplMaintainance));
    sysTableLookup.addLookupfield(fieldNum(EmplMaintainance,EmpType));
    //Add the query to the lookup form
    sysTableLookup.parmQuery(query);
    // Perform the lookup
    sysTableLookup.performFormLookup();
}

override the postBuild method to get the looup,
public void postBuild()
{
    DialogField         dialogField;
    super();
    dialogField = this.bindInfo().getDialogField(this.dataContractObject(),
            methodStr(PMWorkorderContract,parmEmpType));
    dialogField.registerOverrideMethod(methodstr(FormStringControl, lookup), methodstr(PMWorkorderUIBuilder,  lookupEmptype), this);
}


And at last link the UI Builder class to contract class with the attribute

[SysOperationContractProcessingAttribute(classStr(PMWorkorderUIBuilder)),
DataContractAttribute]
class ALE_PMWorkorderContract
{
    TransDate           fromDate; //
    TransDate           toDate;
    ALEEmpType          empType;
}

No comments:

Post a Comment