如何在Dynamics 365中使用JS循环子网格中的行(非当前行)。

问题描述 投票:0回答:1

我可以使用以下方法读取由OnChange触发的Subgrid单元格值 网络资源.

之后,我需要循环读取子网格中剩余的行(除了当前行),并读取每行的每个单元格值。

我想知道如何才能做到这一点?


当前的代码片段。

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
    }
}
javascript microsoft-dynamics
1个回答
1
投票

你应该能够使用 列表 方法来拉动和迭代所有可编辑的网格行,并实现你想要的东西。

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();
        });
    });

阅读更多

© www.soinside.com 2019 - 2024. All rights reserved.