2

我正在尝试在表单中的数据源字段中创建一个简单的查找。

表格和相关表格是 BankAccountTable。

1.- 将新字段 BullCust(扩展 EDT CustAccount)和字段组添加到新扩展 BankAccountTable.MyExtension。

2.- 创建新的表单扩展 BankAccountTable.MyExtension 并向表单添加新组。

这工作正常。但现在我想要一个更简单的查找。在 Ax2012 中,我将覆盖 BankAccountTable\Datasources\BankAccountTable\BullCust\Lookup 方法,如下所示:

public void lookup(FormControl _formControl, str _filterStr)
{
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    SysTableLookup          sysTableLookup;

    sysTableLookup = SysTableLookup::newParameters(tableNum(ExcEC_DocuTypeTable), _formControl);
    queryBuildDataSource = query.addDataSource(tableNum(CustTable));

    sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
    sysTableLookup.addLookupField(fieldNum(CustTable, Party));
    sysTableLookup.addLookupField(fieldNum(CustTable, RecId));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

在 Ax7 中,这不再起作用。尝试了这种方法(基于https://ievgensaxblog.wordpress.com/2016/05/01/ax-7-how-to-override-form-data-source-field-methods-without-overlaying/):

3.- 创建管理查找的类:

public class BullFormBankAccountTable_Handler
{
public static BullFormBankAccountTable_Handler construct()
{
    return new BullFormBankAccountTable_Handler();
}

public void BankAccountTable_BullCust_OnLookup(FormDataObject _formDataObject, FormControl _formControl, str _filterStr)
{

    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    SysTableLookup          sysTableLookup;

    sysTableLookup = SysTableLookup::newParameters(tableNum(BullDocuTypeTable), _formControl);
    queryBuildDataSource = query.addDataSource(tableNum(CustTable));

    sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
    sysTableLookup.addLookupField(fieldNum(CustTable, Party));
    sysTableLookup.addLookupField(fieldNum(CustTable, RecId));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}
}

4.- 创建订阅和链接适当事件的类扩展:

[ExtensionOf(formStr(BankAccountTable))]
final public class BullFormBankAccountTable_Extension
{
[FormDataSourceEventHandler(formDataSourceStr(BankAccountTable, BankAccountTable), FormDataSourceEventType::Initialized)]
public static void BankAccountTable_OnInitialized(FormDataSource _sender, FormDataSourceEventArgs _e)
{
    var overrider = BullFormBankAccountTable_Handler::construct();

    _sender.object(fieldNum(BankAccountTable, BullCust)).registerOverrideMethod(methodStr(FormDataObject, lookup),
        methodStr(BullFormBankAccountTable_Handler, BankAccountTable_BullCust_OnLookup), overrider);
}

}

而且没有结果。我已经调试并正确调用了 BullFormBankAccountTable_Extension.BankAccountTable_OnInitialized()。但生成的查找是标准查找,而不是矿山查找。关于如何执行此操作的任何想法或示例?

(PS:版本Ax7平台更新9)

4

2 回答 2

1

我不会使用类扩展来解决这个问题,而是使用控件的 OnLookup 事件上的事件处理程序。只需订阅事件并在某个事件处理程序类中处理它。

这是一个潜在的代码示例。我在这里假设数据源字段“BullCust”也是表单上的一个控件,因为它覆盖了表单控件而不是数据源字段

public class YourEventHandlers
{
    [FormControlEventHandler(formControlStr(BankAccountTable, BullCust), FormControlEventType::Lookup)]
    public static void PWSCertificateProvince_OnLookup(FormControl sender, FormControlEventArgs e)
    {
        Query                   query = new Query();
        QueryBuildDataSource    queryBuildDataSource;
        SysTableLookup          sysTableLookup;


        sysTableLookup = SysTableLookup::newParameters(tableNum(BullDocuTypeTable), sender);
        queryBuildDataSource = query.addDataSource(tableNum(CustTable));

        sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
        sysTableLookup.addLookupField(fieldNum(CustTable, Party));
        sysTableLookup.addLookupField(fieldNum(CustTable, RecId));

        sysTableLookup.parmQuery(query);
        sysTableLookup.performFormLookup();
    }
}

注意:如果显示/生成框架查找表单,您可能需要根据您的用例取消超级调用。

利用:

  FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
  ce.CancelSuperCall();
于 2018-01-22T20:50:47.890 回答
0

仅使用 FormControl 参数尝试:

public void BankAccountTable_BullCust_OnLookup(FormControl _formControl)
{
    //same code
}

我检查了它并且工作。

于 2021-06-25T12:17:00.693 回答