如何在 CRM 子网格上异步显示创建新按钮?
How to Asynchronously Show a Create New Button On a CRM Sub Grid?
我需要隐藏子网格上的 "Add New" 按钮,直到满足特定条件。调用 Xrm.Page.ui.refreshRibbon
将触发我在启用规则中定义的 JS 函数,但我无法显示 +
按钮。
这是不受支持的,还是有一些方法可以让它发挥作用?
看来你需要做一些额外的技巧。
Refreshing the subgrid command bar
You will find that when the form is loaded, if there is a value in the attribute you have referenced in your enable rule, the Add New button will be visible. If however the value changes, the sub-grid command bar will not automatically refresh to reflect the new state. Upon adding or deleting rows in the sub-grid the command bar is refresh – but this isn’t much use in this case.
The main form command bar can be refreshed using Xrm.Page.ui.refreshRibbon()
however this will not refresh sub-grid command bars. Instead, we can add an onchange event to the fields that are used in our VaueRule and call:
Xrm.Page.data.save();
This will refresh the sub-grids and re-evaluate any of the EnableRules however it will also save any other dirty attributes and so should be used with caution if you do not have auto-save enabled.
A运行 Vinoth 确实找到了一篇很好的文章来描述这个问题,但实际上我发现只需要在网格上调用刷新就足够了。
请务必注意,这不会重新运行启用规则,只是在状态发生变化时显示按钮。
我需要隐藏子网格上的 "Add New" 按钮,直到满足特定条件。调用 Xrm.Page.ui.refreshRibbon
将触发我在启用规则中定义的 JS 函数,但我无法显示 +
按钮。
这是不受支持的,还是有一些方法可以让它发挥作用?
看来你需要做一些额外的技巧。
Refreshing the subgrid command bar
You will find that when the form is loaded, if there is a value in the attribute you have referenced in your enable rule, the Add New button will be visible. If however the value changes, the sub-grid command bar will not automatically refresh to reflect the new state. Upon adding or deleting rows in the sub-grid the command bar is refresh – but this isn’t much use in this case.
The main form command bar can be refreshed using
Xrm.Page.ui.refreshRibbon()
however this will not refresh sub-grid command bars. Instead, we can add an onchange event to the fields that are used in our VaueRule and call:
Xrm.Page.data.save();
This will refresh the sub-grids and re-evaluate any of the EnableRules however it will also save any other dirty attributes and so should be used with caution if you do not have auto-save enabled.
A运行 Vinoth 确实找到了一篇很好的文章来描述这个问题,但实际上我发现只需要在网格上调用刷新就足够了。
请务必注意,这不会重新运行启用规则,只是在状态发生变化时显示按钮。