javascript - 如何使用 Dynamics 365 中的 JS 在子网格中循环行(当前行除外)
问题描述
我能够使用Web 资源读取由 OnChange 触发的子网格单元格值。
之后,我需要遍历子网格中的剩余行(当前行除外)并读取每行的每个单元格值。
我可以知道怎么做吗?
当前代码片段:
function SetNA(context) {
debugger;
//id of the subgrid
var id = formContext.data.entity.getId();
// get the attribute which fired the onchange.
var changedFirstNameAttr = context.getEventSource();
// get the container for the attribute.
var attrParent = changedFirstNameAttr.getParent();
// var FirstName Field Attribute
var changedFirstNameField = attrParent.attributes.get("firstName");
// get the value of the changed first name value
var changedFirstNameValue = changedFirstNameAttr.getValue();
alert(changedFirstNameValue);
if (changedFirstNameValue != null)
{
//loop through other rows in the subgrid, and read each cell value
}
}
解决方案
您应该能够使用getRows方法来拉取和迭代所有可编辑的网格行并实现您想要的。
var gridRows = gridContext.getGrid().getRows();
//loop through each row to get values of each column
gridRows.forEach(function (row, i) {
var gridColumns = row.getData().getEntity().getAttributes();
//loop through each column in row
gridColumns.forEach(function (column, j) {
var atrName = column.getName();
var atrValue = column.getValue();
});
});
推荐阅读
- javascript - 如何使用 vanilla js 附加内联元素
- vstest.console.exe - 使用 vstest.console.exe,如何获取程序集的所有测试方法的完全限定名称?
- solr - Solr 通配符语法仅在搜索文本的末尾起作用?
- python - copy.deepcopy 不会阻止通过引用复制
- java - 即使使用更新的 gradle 文件,也无法解析符号“firebase”
- visual-studio-code - 如何在 VS Code 中为多个主题自定义 textMateRules?
- jbpm - 部署 jbpm 应用程序时命名查询出错
- javascript - 尝试在引导弹出窗口中添加其他表单复选框
- excel - Excel:计算两个匹配单元格的实例
- java - 根据其他bean有条件地选择bean