如何在ListPageInteraction类中获取表单对象?

时间:2011-08-04 07:57:51

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

使用Microsoft Dynamics AX 2012。

我有一个listpage form,其中有一个引用的ListPageInteraction类,只是想更改一些控件的标签/标题。为此我需要做类似的事情:

element.form().design().control('<YourControlName>');

但我无法在ListPageInteraction课程中获得此方法。我决定研究类的初始化方法。但是没有办法从那里获取表格,我怎样才能进入控件并设置标签?

2 个答案:

答案 0 :(得分:5)

common = this.listPage().activeRecord('Table');
if(common.isFormDataSource())
{
    fds = common.dataSource();
    fds.formRun().control(fds.formRun().controlId('ControlOfScreen')).
       userPromptText('New Description');
}

另一个例子来自projProjectTransListPageInteraction.initializeQuery()透视图,从表格projProjectTransactionsListPage上的网格中更改TransDate字段的标签

public void initializeQuery(Query _query)
{
    QueryBuildRange     transDateRange;
    // ListPageLabelChange =>
    Common              externalRecord;
    FormDataSource      frmDs;
    FormRun             formRun;
    FormControl         frmCtrl;
    // ListPageLabelChange <=
    ;

    queryBuildDataSource = _query.dataSourceTable(tableNum(ProjPostTransView));
    transDateRange = SysQuery::findOrCreateRange(queryBuildDataSource, fieldNum(ProjPostTransView, TransDate));

    // Date range is [(today's date - 30)..today's date] if not showing transactions for a particular project.
    // Date range is [(dateNull())..today's date] if showing transactions for a particular project so that all transactions are visible.
    transDateRange.value(SysQuery::range(transStartDate, systemDateGet()));

    this.linkActive(_query);

    // ListPageLabelChange =>
    externalRecord = this.listPage().activeRecord(_query.dataSourceTable(tableNum(ProjPostTransView)).name());//No intrisic function for form DS?
    if(externalRecord.isFormDataSource())
    {
        frmDs   = externalRecord.dataSource();
        formRun = frmDs.formRun();
        if(formRun)
        {
            frmCtrl = formRun.design().controlName(formControlStr(projProjectTransactionsListPage,TransDate));
            if(frmCtrl)
            {
                frmCtrl.userPromptText("newName");
            }
        }
    }
    // ListPageLabelChange <=
}

答案 1 :(得分:2)

我认为不可能从ListPageInteraction获取FormRun对象。 如果你能够做到,剩下的就很容易了:

FormControl fc = formRun.design().controlName(formcontrolstr(formName, controlName));
// etc.