Hi community,

 

I read the article (https://community.creatio.com/questions/add-action-detail) in Creatio community and added a button in the action menu of our order product detail.

But the visibility seems not working. May you help me to adjust the code below? What I

need is to show the button when some detail records are selected, and hide the button otherwise.

 

                     addToolsButtonMenuItems: function(toolsButtonMenu) {

                             this.callParent(arguments);

                             toolsButtonMenu.addItem(this.getButtonMenuSeparator());

                             toolsButtonMenu.addItem(this.getButtonMenuItem({

                               Caption: this.get("Resources.Strings.UsrBtnBatchUpdate"),

                               Click: {"bindTo": "OnButonClick"},

                               Visible: {"bindTo": "IsSelectRecord"}

                             }));

                     },

 

Thanks a lot!

Like 0

Like

2 comments
Best reply

Hi Andrew,

 

Please use the following approach:

methods: {
				addToolsButtonMenuItems: function(toolsButtonMenu) {
					this.callParent(arguments);
					toolsButtonMenu.addItem(this.getButtonMenuSeparator());
					toolsButtonMenu.addItem(this.getButtonMenuItem({
						Caption: {"bindTo": "Resources.Strings.CustomButton"},
						Click: {"bindTo": "onButonClick"},
						Visible: {"bindTo": "getCustomButtonVisible"},
					}));
				},
				getCustomButtonVisible: function() {
					return this.isSingleSelected();
				},
				onButonClick: function() {
					console.log("Clicked!");
				}
			},

there is no IsSelectRecord base attribute that will make the button visible or invisible, thus there are basic methods to make "Edit" or "Copy" buttons enabled\disabled so I've used the logic behind them as an example to make the custom button visible.

Hi Andrew,

 

Please use the following approach:

methods: {
				addToolsButtonMenuItems: function(toolsButtonMenu) {
					this.callParent(arguments);
					toolsButtonMenu.addItem(this.getButtonMenuSeparator());
					toolsButtonMenu.addItem(this.getButtonMenuItem({
						Caption: {"bindTo": "Resources.Strings.CustomButton"},
						Click: {"bindTo": "onButonClick"},
						Visible: {"bindTo": "getCustomButtonVisible"},
					}));
				},
				getCustomButtonVisible: function() {
					return this.isSingleSelected();
				},
				onButonClick: function() {
					console.log("Clicked!");
				}
			},

there is no IsSelectRecord base attribute that will make the button visible or invisible, thus there are basic methods to make "Edit" or "Copy" buttons enabled\disabled so I've used the logic behind them as an example to make the custom button visible.

Oleg Drobina,

Thank you for your guid!. It works for a single detail record selected, like the behavior of "Edit" or "Copy".

What I want is the like the behavior of "Delete", and I found the solution in the academy.

In summary, I just adjusted the code below to approach the behavior like "Delete" action.

 

getCustomButtonVisible: function() {
    var selectedRows = this.get("SelectedRows");
    return selectedRows ? (selectedRows.length > 0) : false;
},

 

Thank you!

Show all comments

Is there a way to hide the button on a detail page when the parent page status has changed upon checking on initialize?

 

I tried to create an attribute that will be set to true when the parent status is 'order processing' and bind it to the visible property of the button but it doesn't work.

 

"className": "Terrasoft.ConfigurationGrid",
"generator": "ConfigurationGridGenerator.generatePartial",
"generateControlsConfig": {"bindTo": "generateActiveRowControlsConfig"},
"changeRow": {"bindTo": "changeRow"},
"unSelectRow": {"bindTo": "unSelectRow"},
"onGridClick": {"bindTo": "onGridClick"},
"activeRowActions": [
	{
		"className": "Terrasoft.Button",
		"style": this.Terrasoft.controls.ButtonEnums.style.TRANSPARENT,
		"tag": "save",
		"markerValue": "save",
		"imageConfig": {"bindTo": "Resources.Images.SaveIcon"},
		"visible": {"bindTo": "IsOrderProcessing"}
	},...
init: function() {
	debugger;
	this.callParent(arguments);
 
	var orderId = this.$MasterRecordId;
	var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
		rootSchemaName: "Order"
	});
 
	esq.addColumn("Status", "Status");
	esq.getEntity(orderId, function (result) {
		debugger;
		if (!result.success) {
			this.showInformationDialog("Data query error");
			return;
		}
		if (result.entity) {
			var orderStatus = result.entity.get("Status");
 
			if (orderStatus.value === "3f7523c5-f066-4bb6-bfd8-b2156fb42f13") { // Order Processing
				this.set("IsOrderProcessing", true);
			}
			else {
				this.set("IsOrderProcessing", false);
			}
		}
 
	}, this);
}

 

Like 0

Like

1 comments

Hi Community, has anybody have an idea on this?

Show all comments