Featured image of post Dynamics CRM - Set editable subgrid columns to read-only

Dynamics CRM - Set editable subgrid columns to read-only

Set editable subgrid columns to read-only.

All columns are set 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);
        });
}

Set specified columns to read-only

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

Binding

Open the form, select the editable subgrid, and bind the method to it (remember to check ‘Pass execution context as the first parameter’).

为可编辑子网格绑定Javascript

Built with Hugo
Theme Stack designed by Jimmy
发表了19篇文章 · 总计14.48k字