Featured image of post Dynamics CRM - 设置可编辑子网格列为只读

Dynamics CRM - 设置可编辑子网格列为只读

Set editable subgrid columns to read-only.

所有列都设置为只读

1
2
3
4
5
6
7
8
9
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);
        });
}

指定列设置为只读

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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);
        }
    });
}

绑定

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

为可编辑子网格绑定Javascript

使用 Hugo 构建
主题 StackJimmy 设计
发表了19篇文章 · 总计21.42k字