Dynamics AX 2012 - 网格控件将 PhysicalTableInstance 链接到 TempTable,插入的第一条记录不会出现在网格中,之后很好
Dynamics AX 2012 - Grid Control linkPhysicalTableInstance to TempTable, first record inserted doesn't appear in Grid, fine afterwards
问题与在 AX 2012 中使用带有网格控件的 table 缓冲区有关,其中第一次添加到表单的 tempDB 不会实时显示(但会持续显示,随后的添加工作正常)。
我在动态社区 MSDN 上的 DAX 传奇人物 Martin Dráb 和 Brandon Weise 的帮助下解决了这个问题,但我在 SO 上发帖以防它帮助其他人(因为我找不到任何接近的东西),我不认为在 SO 上添加更多 Dynamics AX 内容会伤害社区。关于 tempDB 的物理 tables link 以及它们与表单数据源的关系,还需要学习一些知识。
原帖:https://community.dynamics.com/ax/f/33/t/225120
问题:
- 我有一个向导,可以在 运行 时生成一个包含网格控件的新表单。
- 向导将对其其中一个临时表的引用传递给表单,其中我在 运行time 表单的数据源 init() 方法中使用 linkPhysicalTableInstance。
- GridControl 有一个添加新记录按钮,可将记录插入到 tmp table 引用中。
- 新记录正确保存到参考温度table,并在运行时间窗体关闭和重新打开时网格中显示但是插入后不会立即显示在网格中。
- 更奇怪的是,在创建 运行 时间表单后,插入一条记录然后关闭,随后的 运行 时间表单确实会立即显示新记录插入,而无需重新打开。下面是一些代码片段。
为什么这种行为只发生在第一次将数据插入临时 table 时,但在 运行time 形式的后续 运行 中显示正常?
创建运行时间表格:
args = new Args(formstr(RunTimeFormName));
formRun = classFactory.formRunClass(args);
formRun .parmRuntimeFormsGridTmpDS(sysWizard.ReferenceToWizardsTableTmp()); // Passing a reference for Wizards tmpTable to form
formRun .init();
formRun .run();
formRun .wait();
formRun .detach();
运行时窗体的 parmDataSourceMethod:
public void parmRuntimeFormsGridTmpDS(CommentsGridTmp _ReferenceToWizardsTableTmp)
{
ReferenceToWizardsTableTmp = _ReferenceToWizardsTableTmp;
}
DataSource init() method:
public void init()
{
super();
RuntimeFormsGridTmpDS.linkPhysicalTableInstance(ReferenceToWizardsTableTmp);
}
RunTime 窗体的新按钮点击方法:
void clicked()
{
int64 numRows;
;
// Refresh records loaded in grid DS to ensure correct number of records for setting initial index number
// Note: SomeId is passed in Args() record, its passing fine as is the number of rows count - and replacing with a static value has no effect.
select count(RecId) from ReferenceToWizardsTableTmp
where ReferenceToWizardsTableTmp.SomeId == someId;
numRows = ReferenceToWizardsTableTmp.RecId;
ReferenceToWizardsTableTmp.Comment = "Comment " + int642str(numRows + 1);
ReferenceToWizardsTableTmp.Filename = "";
ReferenceToWizardsTableTmp.someId = someId;
ReferenceToWizardsTableTmp.insert();
element .Task(#TaskF5);
// super();
}
所以如上所述,第一次创建运行时间窗体并插入记录时,它不显示。重新打开表单将正常显示插入的数据。此外,在重新打开表单后,插入的任何新记录都会实时显示在网格中。
我最初认为它必须与 linkToPhysicalTable 以及网格字段查找要显示的记录的位置有关...
顺便说一下,如果您有更好的答案或解释,请随时贡献。
解决方案
我有一个可行的解决方案,据此我 运行 在 linkPhysicalTableInstance 操作(delete_from tmptable 语句具有相同的效果并且更便宜),尽管它是空的,但它会初始化缓冲区引用。
linkPhysicalTableInstance 操作然后在第一个 运行 成功,因为缓冲区正确存在 - 并且写入表单 DS 的更改现在是持久的并反映在调用向导的缓冲区引用中。
此外(来自 Brandon Weise):
如果您碰巧在代码中跳层,请注意以下小问题。
https://community.dynamics.com/ax/b/dynamicsaxexperience/archive/2016/01/24/2012-unexpected-degeneration-of-insert-recordset-into-tempdb-buffer
我发现对调查有用的技术
(感谢 Brandon Weise 和 Martin Dráb)
似乎确实使用 .linkPhysicalTableInstance(..) 来更改其后与表单数据源关联的基础温度 table
已经初始化会产生一些奇怪的行为。这似乎
即使您可以使用 .getPhysicalTableName() 进行演示也是如此
他们 link 正确编辑。
一种有用的方法是创建表单,并且
调用 .init(),但尚未调用 .运行()。然后使用
.linkPhysicalTableInstance() 到 link 新创建的临时 table
将数据源作为外部临时 table 缓冲区的基础。在
换句话说,而不是试图移植你已经创建的
temp table 到表单的数据源中,让表单创建临时文件
table,然后让调用者把那个temptable移植到自己的
使用 .linkPhysicalTableInstance() 缓冲。然后插入记录,
然后调用.运行()。如有必要,在表单上调用 .executeQuery()
.运行().
之后的数据源
我采用散弹枪的方式进行打印
table 名称在整个初始化和操作过程中,同时
两个 table 最终 link 正确地使用相同的 table
名字,他们采取迂回的方式到达那里。
在调试时检查临时 table 的内容,从 SQL Server Management Studio 使用:
设置事务隔离级别读取未提交;
select * 来自 tempdb..t107946_BE044A13A9C24283897CA1B59607CBD2;
如果您的 table 名字来自
.getPhysicalTableName(),但即使您不确切地知道它,
通过反复试验通常很容易找到它。 select *
来自 tempdb.sys.tables; table 当然会以 "t" 开头,并且
table 号。通常它是最近创建的,所以
按 create_date desc 排序会将其浮动到顶部,但当然
可以有一堆。
回顾 Methods on a Form Data Source 在通过数据源处理记录时可以使用哪些方法。
问题与在 AX 2012 中使用带有网格控件的 table 缓冲区有关,其中第一次添加到表单的 tempDB 不会实时显示(但会持续显示,随后的添加工作正常)。
我在动态社区 MSDN 上的 DAX 传奇人物 Martin Dráb 和 Brandon Weise 的帮助下解决了这个问题,但我在 SO 上发帖以防它帮助其他人(因为我找不到任何接近的东西),我不认为在 SO 上添加更多 Dynamics AX 内容会伤害社区。关于 tempDB 的物理 tables link 以及它们与表单数据源的关系,还需要学习一些知识。
原帖:https://community.dynamics.com/ax/f/33/t/225120
问题:
- 我有一个向导,可以在 运行 时生成一个包含网格控件的新表单。
- 向导将对其其中一个临时表的引用传递给表单,其中我在 运行time 表单的数据源 init() 方法中使用 linkPhysicalTableInstance。
- GridControl 有一个添加新记录按钮,可将记录插入到 tmp table 引用中。
- 新记录正确保存到参考温度table,并在运行时间窗体关闭和重新打开时网格中显示但是插入后不会立即显示在网格中。
- 更奇怪的是,在创建 运行 时间表单后,插入一条记录然后关闭,随后的 运行 时间表单确实会立即显示新记录插入,而无需重新打开。下面是一些代码片段。
为什么这种行为只发生在第一次将数据插入临时 table 时,但在 运行time 形式的后续 运行 中显示正常?
创建运行时间表格:
args = new Args(formstr(RunTimeFormName));
formRun = classFactory.formRunClass(args);
formRun .parmRuntimeFormsGridTmpDS(sysWizard.ReferenceToWizardsTableTmp()); // Passing a reference for Wizards tmpTable to form
formRun .init();
formRun .run();
formRun .wait();
formRun .detach();
运行时窗体的 parmDataSourceMethod:
public void parmRuntimeFormsGridTmpDS(CommentsGridTmp _ReferenceToWizardsTableTmp)
{
ReferenceToWizardsTableTmp = _ReferenceToWizardsTableTmp;
}
DataSource init() method:
public void init()
{
super();
RuntimeFormsGridTmpDS.linkPhysicalTableInstance(ReferenceToWizardsTableTmp);
}
RunTime 窗体的新按钮点击方法:
void clicked()
{
int64 numRows;
;
// Refresh records loaded in grid DS to ensure correct number of records for setting initial index number
// Note: SomeId is passed in Args() record, its passing fine as is the number of rows count - and replacing with a static value has no effect.
select count(RecId) from ReferenceToWizardsTableTmp
where ReferenceToWizardsTableTmp.SomeId == someId;
numRows = ReferenceToWizardsTableTmp.RecId;
ReferenceToWizardsTableTmp.Comment = "Comment " + int642str(numRows + 1);
ReferenceToWizardsTableTmp.Filename = "";
ReferenceToWizardsTableTmp.someId = someId;
ReferenceToWizardsTableTmp.insert();
element .Task(#TaskF5);
// super();
}
所以如上所述,第一次创建运行时间窗体并插入记录时,它不显示。重新打开表单将正常显示插入的数据。此外,在重新打开表单后,插入的任何新记录都会实时显示在网格中。 我最初认为它必须与 linkToPhysicalTable 以及网格字段查找要显示的记录的位置有关...
顺便说一下,如果您有更好的答案或解释,请随时贡献。
解决方案
我有一个可行的解决方案,据此我 运行 在 linkPhysicalTableInstance 操作(delete_from tmptable 语句具有相同的效果并且更便宜),尽管它是空的,但它会初始化缓冲区引用。
linkPhysicalTableInstance 操作然后在第一个 运行 成功,因为缓冲区正确存在 - 并且写入表单 DS 的更改现在是持久的并反映在调用向导的缓冲区引用中。
此外(来自 Brandon Weise):
如果您碰巧在代码中跳层,请注意以下小问题。 https://community.dynamics.com/ax/b/dynamicsaxexperience/archive/2016/01/24/2012-unexpected-degeneration-of-insert-recordset-into-tempdb-buffer
我发现对调查有用的技术
(感谢 Brandon Weise 和 Martin Dráb)
似乎确实使用 .linkPhysicalTableInstance(..) 来更改其后与表单数据源关联的基础温度 table 已经初始化会产生一些奇怪的行为。这似乎 即使您可以使用 .getPhysicalTableName() 进行演示也是如此 他们 link 正确编辑。
一种有用的方法是创建表单,并且 调用 .init(),但尚未调用 .运行()。然后使用 .linkPhysicalTableInstance() 到 link 新创建的临时 table 将数据源作为外部临时 table 缓冲区的基础。在 换句话说,而不是试图移植你已经创建的 temp table 到表单的数据源中,让表单创建临时文件 table,然后让调用者把那个temptable移植到自己的 使用 .linkPhysicalTableInstance() 缓冲。然后插入记录, 然后调用.运行()。如有必要,在表单上调用 .executeQuery() .运行().
之后的数据源我采用散弹枪的方式进行打印 table 名称在整个初始化和操作过程中,同时 两个 table 最终 link 正确地使用相同的 table 名字,他们采取迂回的方式到达那里。
在调试时检查临时 table 的内容,从 SQL Server Management Studio 使用:
设置事务隔离级别读取未提交;
select * 来自 tempdb..t107946_BE044A13A9C24283897CA1B59607CBD2;
如果您的 table 名字来自 .getPhysicalTableName(),但即使您不确切地知道它, 通过反复试验通常很容易找到它。 select * 来自 tempdb.sys.tables; table 当然会以 "t" 开头,并且 table 号。通常它是最近创建的,所以 按 create_date desc 排序会将其浮动到顶部,但当然 可以有一堆。
回顾 Methods on a Form Data Source 在通过数据源处理记录时可以使用哪些方法。