Today we see how to get multi-select lookup in the report dialog. This is used to sys operation Framework also. We have to fetch selected records in dp class or service class. For this, I wrote logic in the below classes.
Contract Class :
[ DataContractAttribute, SysOperationContractProcessingAttribute(classstr(TestUIBuilderClass)) ] class TestContractClass { List vendAccountList; [ DataMemberAttribute("Vendor"), AifCollectionTypeAttribute("Vendor", Types::String), SysOperationLabelAttribute(literalstr("Vend account")), SysOperationHelpTextAttribute(literalstr("Vend account.")), //SysOperationGroupMemberAttribute('Group'), SysOperationDisplayOrderAttribute('1') ] public List parmVendorList(List _vendAccountList = vendAccountList) { vendAccountList = _vendAccountList; return vendAccountList; } }
-------------------------------------------------------------------------------------------------------------
UI Builder Class:
class TestUIBuilderClass extends SrsReportDataContractUIBuilder { TestContractClass myContractClass; DialogField dialogField; container con; public void build() { // super(); // Add group to dialog //Dialog dialogObject = this.dialog(); // dialogObject.addGroup('Group'); myContractClass = this.dataContractObject() as TestContractClass; dialogField = this.addDialogField(methodStr(TestContractClass, parmVendorList), TestContractClass); } public void postBuild() //or postRun() we can use any method. { super(); myContractClass = this.dataContractObject() as TestContractClass; dialogField = this.bindInfo().getDialogField(TestContractClass, methodStr(TestContractClass, parmVendorList)); dialogField.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(TestUIBuilderClass, VendorLookup), this); //dialogField.registerOverrideMethod(methodStr(FormStringControl, modified), methodStr(TestUIBuilderClass, Vendormodified), this); // modified method. //if (dialogField) //{ // dialogField.lookupButton(2); //} } public void VendorLookup(FormStringControl _control) { Query query = new Query(); QueryBuildDataSource vendQBD; // QueryBuildFieldList fieldList; vendQBD = query.addDataSource(tableNum(VendTable)); //qbds1 = qbds.addDataSource(tableNum(DirPartyTable)); //qbds1.relations(True); //qbds1.fields().clearFieldList(); //fieldList = qbds.fields(); //fieldList.addField(fieldNum(DirPartyTable, Name)); //fieldList.dynamic(QueryFieldListDynamic::No); vendQBD.addSelectionField(fieldNum(VendTable, AccountNum)); SysLookupMultiSelectGrid::lookup(query, _control, _control, _control, con); } }
-------------------------------------------------------------------------------------------------------------
DP Class
[ SRSReportQueryAttribute (querystr(Myquery)), SRSReportParameterAttribute(classstr(TestContractClass)) ] class TestDPClass extends SRSReportDataProviderBase //SrsReportDataProviderPreProcess { MyTable myTable; List vendorList; Vendtable vendTable; [SRSReportDataSetAttribute(tableStr('MyTable'))] public MyTable getTempMyTable() { select MyTable; return MyTable; } private Query buildQuery(Query _query,List _vendorList) { ListIterator listIterator = new ListIterator(_vendorList); while(listIterator.more()) { _query.dataSourceTable(tablenum(VendTable)).addRange(fieldnum(VendTable, AccountNum)).value(queryValue(listIterator.value())); listIterator.next(); } return _query; } public void processReport() { QueryRun queryRun; TestContractClass contract = this.parmDataContract() as TestContractClass; Query query = this.parmQuery(); ; vendorList = contract.parmVendorList(); queryRun = new QueryRun(vendorList.empty() ? query : this.buildQuery(this.parmQuery(), vendorList)); while(queryRun.next()) { vendTable = queryRun.get(tablenum(VendTable)); this.insertIntoTempTable(); } } private void insertIntoTempTable() { myTable.AccountNum = vendTable.AccountNum; myTable.VendGroup = vendTable.VendGroup; myTable.insert(); } }
Keep Daxing!!
No comments:
Post a Comment