Hi community,

I'm trying to disable the columns of an editable detail to make them read only and I have read many articles about it, but I'm still having a problem that I can't fix.



I wrote this code in the GridDetail to disable the fields but I noticed that for some of the columns of the detail is not working.

getCellControlsConfig: function(entitySchemaColumn) {
    if (!entitySchemaColumn) {
        return;
    }
    var columnName = entitySchemaColumn.name;
    var enabled = (entitySchemaColumn.usageType !== this.Terrasoft.EntitySchemaColumnUsageType.None) &&
        !this.Ext.Array.contains(this.systemColumns, columnName);
    var config = {
        itemType: this.Terrasoft.ViewItemType.MODEL_ITEM,
        name: columnName,
        labelConfig: {visible: false},
        caption: entitySchemaColumn.caption,
        enabled: enabled
    };
    if (!this.values.IsEnabled) {
        config.enabled = false;
        //config.labelConfig.enabled = false;
        //this.set("Is"+columnName+"enabled", false);
    }
    if (entitySchemaColumn.dataValueType === this.Terrasoft.DataValueType.LOOKUP) {
        config.showValueAsLink = false;
    }
    if (entitySchemaColumn.dataValueType !== this.Terrasoft.DataValueType.DATE_TIME &&
        entitySchemaColumn.dataValueType !== this.Terrasoft.DataValueType.BOOLEAN) {
        config.focused = {"bindTo": "Is" + columnName + "Focused"};
    }
    console.log(config);
    return config;
},

Debugging I have discovered that the detail adds to the labelConfig the property "enabled" which is binded to an attribute ("isProductenabled").

I tried to force the property writing it in the method and I also tried to set the attribute manually, but it's not working... do you have any idea?



Let me know.

Thanks in advance.



Best regards,

Luca

Like 0

Like

5 comments
Best reply

Luca Tavasanis,

While I was debugging I have noticed that the properties of the labelConfig that enabled some of the fields where added in the method: "applyBusinessRulesForActiveRow: function(id, gridLayoutItems)" and to fix the issue I just added this method in the client module.

You can lock the fields in the editable detail using business rules on the page for the detail, rather than in code. On the page for the detail, add a business rule to make the field not editable. Something like 

Condition: Boolean true = Boolean false (something that is never true)

Then: Make field editable (the condition is never true, so field is never editable)

The business rule will apply to the detail list and the fields will not be editable in the detail list.

Ryan

Hi Ryan,

I'm actually working with the BaseGridDetail so I can't lock it with a business rule... do you have any other idea?

 

Thanks anyway.

Luca

Luca Tavasanis,

IIRC to do it in code I usually do it like this (but unable to verify if this is correct at the moment)

getCellControlsConfig: function(entitySchemaColumn) {
    // get config from base 
    var config = this.callParent(arguments);
    var columnName = entitySchemaColumn.name;
 
    // if this is the column I want to disable
    if (columnName === "UsrMyColumn") {
        Ext.apply(config, {
            enabled: false
        });
    }
 
    return config;
}

Hopefully that gets you closer, of course, if you're wanting to disable all, you could just remove the if to check the column it's for.

Ryan

Ryan Farley,

I just tried what you suggested but unfortunately it's not working... it returns an error when I use this.callParent(arguments);.

Thank you anyway.



Luca

Luca Tavasanis,

While I was debugging I have noticed that the properties of the labelConfig that enabled some of the fields where added in the method: "applyBusinessRulesForActiveRow: function(id, gridLayoutItems)" and to fix the issue I just added this method in the client module.

Show all comments