使用Microsoft Dynamics AX 2012。
我有一个listpage form
,其中有一个引用的ListPageInteraction
类,只是想更改一些控件的标签/标题。为此我需要做类似的事情:
element.form().design().control('<YourControlName>');
但我无法在ListPageInteraction
课程中获得此方法。我决定研究类的初始化方法。但是没有办法从那里获取表格,我怎样才能进入控件并设置标签?
答案 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.