Question

How to hide button action

I tried to remove the button by validating the status field, but it doesn't work, can anyone help?

 

Like 0

Like

3 comments

You need to simply override the logic of the getActions method:

getActions: function() {
                var actionMenuItems = this.callParent(arguments);
                actionMenuItems.addItem(this.getActionsMenuItem({ 
                    Type: "Terrasoft.MenuSeparator",
                    Caption: ""
                }));
                actionMenuItems.addItem(this.getActionsMenuItem({
                    "Caption": "Some caption 1 here",
                    "Tag": "runProcess",
                    "Enabled": true
                }));
                var itemToRemove = [];
                actionMenuItems.each(function(item) {
                    if (item.values.Caption == "some caption here" || item.values.Caption == "Escalation") {
                        itemToRemove.push(item);
                    }
                });
                itemToRemove.forEach((item) => actionMenuItems.remove(item));
                return actionMenuItems;
            }, 

actionMenuItems.remove(item) performs the removal, and you can also add an additional check here.

Oleg Drobina,

thanks for answered, but my case is have a vlidation status field, when i try to use getAction method, the field is undifined, any solution with my case? 

Dwi Ariyanto,

 

My only suggestion is to use the "enabled" property instead for the "visible" property. What should be done is remove that action from your screenshot completely (without any conditions, simply remove it) and add a new one that will have the "enabled" property connected to some method. Like this:

 

As a result the action will be only enabled if the case category (in my case) is "Service request".

Show all comments