D365 – 设置可编辑子网格列为只读(JS)

全部列为只读

JAVASCRIPT
Disabled_XXXXX_SubGridOnSelect: function (ExecutionContext) {
    let that = this;
    let objFormContext = ExecutionContext.getFormContext();
    let entObject = objFormContext.data.entity;
    entObject.attributes.forEach(function (attribute) {
            let allColumnControl = attribute.controls.get(0);
            allColumnControl.setDisabled(true);
        });
}
点击展开查看更多

指定列为只读

JAVASCRIPT
Disabled_XXXXX_SubGridOnSelect: function (ExecutionContext) {
    let objFormContext = ExecutionContext.getFormContext();
    let entObject = objFormContext.data.entity;
    entObject.attributes.forEach(function (attribute) {
        let columnName = attribute.getName();
        if (
            columnName == "your field name 1" ||
            columnName == "your field name 2" ||
            columnName == "your field name 3" ||
            columnName == "your field name 4" ||
            columnName == "your field name 5" ||
            columnName == "your field name 6") {
            attribute.controls.get(0).setDisabled(true);
        }
    });
}
点击展开查看更多

绑定

打开表单,选择可编辑子网格,然后为其绑定方法即可(记得勾选 将执行上下文作为第一个参数传递 )。

Bind JavaScript to Editable Subgrid

版权声明

作者: Donghai

链接: https://mgrowup.com/posts/d365/set-editable-subgrid-columns-to-read-only/

许可证: CC BY-NC-SA 4.0

文章已根据知识共享署名-非商业性使用-相同方式共享4.0国际许可协议授权。请注明来源,仅非商业使用,并保持相同的许可协议。

评论

开始搜索

输入关键词搜索文章内容

↑↓
ESC
⌘K 快捷键