Question

Disable button on detail editable list

Hello, please help us how to enable/disable button on editable list in detail?

ex: i want to disable or hide the view button, you can see the code on the below

 

 

Like 0

Like

3 comments

Hello Georges,

Could you please specify with button do you mean exactly?

Best regards,

Bogdan

Bogdan,

Hello Bogdan,

 

Well, I want to Enable or Hide the 'View' button in detail editable list, following the below images:

 

 

I did two ways:

 

Code1:

 

 

 

Code2:

 

attributes: {
              "IsEditable": {
                dataValueType: Terrasoft.DataValueType.BOOLEAN,
                type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
                value: true
            },
            "IsBtnEnabled": {
                    type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
                    dataValueType: Terrasoft.DataValueType.BOOLEAN,
            },
},
diff: /**SCHEMA_DIFF*/
[
{
                "operation": "merge",
                "name": "DataGrid",
                "parentName": "Detail",
                "propertyName": "items",
                "values": {
                    "activeRowActions": [],
                    "activeRowAction": {"bindTo": "onActiveRowAction"}
                }
    },
            {
                "operation": "merge",
                "name": "DataGrid",
                "values": {
                    "className": "Terrasoft.ConfigurationGrid",
                    "generator": "ConfigurationGridGenerator.generatePartial",
                    "generateControlsConfig": {"bindTo": "generateActiveRowControlsConfig"},
                    "changeRow": {"bindTo": "changeRow"},
                    "unSelectRow": {"bindTo": "unSelectRow"},
                    "onGridClick": {"bindTo": "onGridClick"},
                    "activeRowActions": [
                        //View
                        {
                            "className": "Terrasoft.Button",
                            "style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
                            "tag": "view",
                            "markerValue": "view",
                            //"enabled": {"bindTo": "IsBtnEnabled"},
                            "visible": {"bindTo": "IsBtnEnabled"},
                            "caption": "View",
                        },    
                    ],
                    "initActiveRowKeyMap": {"bindTo": "initActiveRowKeyMap"},
                    "activeRowAction": {"bindTo": "onActiveRowAction"},
                    "multiSelect": {"bindTo": "MultiSelect"}
                }
            },
]
method:
{
    init: function(){
        if(field==""){ this.set("IsBtnEnabled",false);}
        else{this.set("IsBtnEnabled",true);}        
        
    }
}

 

 

 

Georges,

 

Hi,

 

It's easier to disable the button (we will make sure that the button does nothing in case some conditions in the active row are not met). To do that override the onActiveRowAction method in your detail schema. For example:

onActiveRowAction: function(buttonTag, primaryColumnValue) {
				var checkButtonTag = buttonTag == "view";
				var activeRow = this.getActiveRow();
				var usrNameValue = activeRow.get("UsrName");
				if (checkButtonTag && usrNameValue != "Test click") {
					return;
				}
				this.mixins.ConfigurationGridUtilitiesV2.onActiveRowAction.call(this, buttonTag, primaryColumnValue);
			},

As a result if the active row (a current selected row in the detail) has the value that differs from the "Test click" in the "UsrName" column than the click action on the button will do nothing = action is disabled.

 

Best regards,

Oscar

Show all comments