uli*_*ses 5 forms x++ axapta args dynamics-ax-2012-r2
我想在两个表单之间传递多个记录.用户打开Form-A,选择多个记录,然后单击打开Form-B的按钮.在Form-B中有两个(或更多)StringEdit
控件,它们应显示所选记录的值.
我知道如何只传递一条记录,为此我在Form-B的方法中使用以下代码:
if (element.args().parmEnumType() == enumNum(NoYes)
&& element.args().parmEnum() == NoYes::Yes)
{
myTable = element.args().record();
stringEdit.text(myTable.Field);
}
Run Code Online (Sandbox Code Playgroud)
我应该如何更改我的代码,以便我可以将另一个StringEdit
控件的文本设置为用户选择的下一条记录的字段值?
为此,您可以使用an args
来传递您需要在Form-A中准备的记录,如下所示(以SalesTable为例);
int recordsCount;
SalesTable salesTable;
container con;
Args args = newArgs();
// gets the total records selected
recordsCount = salesTable_ds.recordsMarked().lastIndex();
salesTable = salesTable_ds.getFirst(1);
while(salesTable)
{
// storing recid of selected record in container
con = conIns(con,1, salesTable.RecId);
salesTable = SampleTable_ds.getNext(); // moves to next record
}
// passing container converted to string
args.parm(con2Str(con,','));
Run Code Online (Sandbox Code Playgroud)
然后在你的Form-B上,你需要覆盖init()
方法来读取你创建的args,
为了从收件人中检索传递的参数.覆盖新表单的init()方法,如图所示
public void init()
{
container con;
int i;
super();
// string to container
con = str2con(element.args().parm(),'','');
// for sorting
for(i = 1;i<= conLen(con) ;i++)
{
salesTable_ds.query().dataSourceTable(Tablenum(SalesTable)).addRange(fieldNum(SalesTable,RecId)).value(SysQuery::value(conPeek(con,i)));
}
}
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你.
取自Ax-Forum