如何根据AX 2012 AOT报告中的另一个对话框在报告对话框中的对话框上过滤查找值?

时间:2013-01-24 12:46:31

标签: x++ axapta dynamics-ax-2012

如何在“报告”对话框中实现自定义查找。

例如,我的报告对话框中有两个字段1)Custgroup 2)CustAccount

如果我在第一个字段中选择了一个特定的cust组,那么第二个字段查找应该只显示属于这个cust组的客户。

//class

    public class ReportRun extends ObjectRun
    {

        DialogField dialogcustGroup,dialogcustaccount ;
        CustTable  obj_CustTable ;
    }

   //dialog method
   public Object dialog(Object _dialog)
{
    DialogRunbase dialog = _dialog;
    DialogGroup     toFromGroup;
    Args _args;
    str accountnum,custGroup;
    ;
   // _args =  new Args();
   //  obj_dev_CustTable = _args.record(); 
    //accountnum = obj_dev_CustTable.AccountNum;

    dialogcustGroup = dialog.addFieldValue(extendedTypeStr(CustGroup),CustGroup,"");

    while select obj_CustTable
         where obj_CustTable.AccountNum == dialogcustGroup .value()
    {
         CID     =  obj_dev_CustTable.CID;
     dialogcustaccount =dialog.addFieldValue(ExtendedTypeStr(AccountNum),accountnum,"CID");
    }


    return dialog;
}  

任何帮助都会很棒!!!!

3 个答案:

答案 0 :(得分:1)

执行此操作的最佳方法是覆盖指定DialogField上的lookup()方法。请参阅下面的示例 - 它可以正常工作。

class CustomizedLookup extends RunBase
{
   DialogRunbase               dialog;
   DialogField                 dFieldCustGroup;
   DialogField                 dFieldCustAccount;
   CustGroupId                 fetchedCustGroup;
   CustAccount                 fetchedAccountNum;
}
protected Object dialog()
{
   dialog = super();

   FieldCustGroup = dialog.addField(extendedTypeStr(CustGroupId),"sysLabel1");
   dFieldCustGroup.allowEdit(true);

   dFieldCustAccount = dialog.addField(extendedTypeStr(CustAccount),"sysLabel1");
   dFieldCustAccount.allowEdit(false);

   return dialog;
}
public void dialogPostRun(DialogRunbase _dialog)
{
   super(_dialog);

// allow to call the event methods 
// of this class (e.g. Fld1_1_modified() method)
   _dialog.dialogForm().formRun().controlMethodOverload(true);
   _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}
private boolean Fld1_1_modified() // dFieldCustGroup
{
   FormStringControl   control;
   boolean             isFieldModified;

   control = dialog.formRun().controlCallingMethod();

   isFieldModified = control.modified();

   if(isFieldModified)
   {
       fetchedCustGroup   = dFieldCustGroup.value();
       dFieldCustAccount.allowEdit(true);
   }
   return isFieldModified;
}
private void Fld2_1_lookup() //dFieldCustAccount
{
   FormStringControl control = dialog.formRun().controlCallingMethod();
   SysTableLookup sysTableLookup =  SysTableLookup::newParameters(tablenum(CustTable),control);
   Query                   query = new Query();
   QueryBuildDataSource    queryBuildDataSource;
   QueryBuildRange         queryBuildRange;

   queryBuildDataSource = query.addDataSource(TableNum(CustTable));
   queryBuildRange = queryBuildDataSource.addRange(FieldNum(CustTable, CustGroup));
   queryBuildRange.value(fetchedCustGroup);  

   sysTableLookup.addLookupfield(fieldnum(CustTable, AccountNum));
   sysTableLookup.addLookupfield(fieldnum(CustTable, CustGroup));
   sysTableLookup.parmQuery(query);
   sysTableLookup.performFormLookup();
}
public boolean getFromDialog()
{
   boolean ret;

   ret = super();

   fetchedAccountNum = dFieldCustAccount.value();

   return ret;
}
static void main(Args _e)
{
   CustomizedLookup customizedLookup;

   customizedLookup = new CustomizedLookup();

   if (customizedLookup.prompt())
   {
       customizedLookup.run();
       // do some actions with your data 
       customizedLookup.theAction();         
   }
}
private void theAction()
{
   info(strFmt("Customer Group: %1",fetchedCustGroup));
   info(strFmt("Account Number: %1",fetchedAccountNum));
}

答案 1 :(得分:0)

应该声明更多方法,如pack,unpack和main方法

答案 2 :(得分:0)

     public class CustAmountCalculation extends RunBase
{
    DialogField fieldAccount;
    CustAccount custAccount;

}

    public Object dialog()
{

    Dialog dialog;
    DialogGroup groupCustomer;
    dialog = super();
    fieldAccount = dialog.addField(extendedTypeStr(custAccount), "CustomerAccount");
    return dialog;
}

    public boolean getFromDialog()
{
    custAccount = fieldAccount.value();
    return super();
}

    public container pack()
{
    return conNull();
}


    public void run()
{
    CustTable custTable;
    CustTrans custTrans;
    ;

    select sum(AmountMST) from custTrans where custTrans.AccountNum == custAccount;
    info("You have enetered customer information");
    info(strfmt("Account: %1", custAccount));
    info(strFmt("Amount: %1", custTrans.AmountMST));
}

    public boolean unpack(container _packedClass)
{
    return true;
}

    public static void main(Args _args)
{
    CustAmountCalculation custAmountCalculation = new CustAmountCalculation();
    if (CustAmountCalculation.prompt())
    {
        CustAmountCalculation.run();
    }
}