Hi,
I am using a button inside the detail in account section.Here we are using one boolean filed called Manager(DB name is UsrManager) if the boolean is tick mark only button have to show otherwise it have to hide. can any one help me on this how to hide.
{
"operation": "insert",
"parentName": "ActionButtonsContainer",
"propertyName": "items",
"name": "Manager",
"values": {
itemType: Terrasoft.ViewItemType.BUTTON,
caption: { bindTo: "Resources.Strings.Manager" },
click: { bindTo: "" },
"layout": {
"column": 1,
"row": 6,
"colSpan": 1
}
}
}
Thanks&Regards,
Harish.Yamalapati
Like
Hi Harish,
You need to specify visible property in diff and add method that should return boolean value based on the condition
If Manger field is selected method should return true otherwise it should return false
I have attached code for your reference
{
"operation": "insert",
"parentName": "ActionButtonsContainer",
"propertyName": "items",
"name": "Manager",
"values": {
itemType: Terrasoft.ViewItemType.BUTTON,
caption: { bindTo: "Resources.Strings.Manager" },
"visible": {"bindTo": "buttonVisibility"}
click: { bindTo: "" },
"layout": {
"column": 1,
"row": 6,
"colSpan": 1
}
}
}
In method, specify following code
buttonVisibility: function(){
var booleanVal = this.get("UsrManager");
var status;
if(booleanVal === true)
{
status = true;
}
else{
status = false;
}
return status;
}
Regards,
Akshaya Gajendran
There is one more solution.
define("AccountPageV2", [], function() {
return {
// Name of the section object schema.
entitySchemaName: "Account",
// Method of the section view model.
attributes: {
"isButtonVisible": {
"dataValueType": Terrasoft.DataValueType.BOOLEAN,
"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN
},
"codeIsChanged": {
dataValueType: Terrasoft.DataValueType.Text,
dependencies: [{
columns: ["Code"],
methodName: "onCodeChanged"
}]
}
},
methods: {
setVisibility: function(){
var param = this.get("Code");
if (param === "1") {
this.set("isButtonVisible", true);
} else {
this.set("isButtonVisible", false);
}
},
onCodeChanged: function(){
this.setVisibility();
},
onEntityInitialized: function() {
this.callParent(arguments);
this.setVisibility();
}
},
//Display button in the section.
diff: /**SCHEMA_DIFF*/[
// Metadata for adding a custom button to a section.
{
// The operation of adding a component to the page is in progress..
"operation": "insert",
// The meta name of the parent container to which the button is added.
"parentName": "AccountPageV2CommonControlGroupControlGroup-wrap",
// The button is added to the parent component's collection.
"propertyName": "items",
// The meta-name of the button to be added.
"name": "MainContactSectionButton",
// Properties passed to the component's constructor.
"values": {
// The type of the component to add is the button.
"itemType": Terrasoft.ViewItemType.BUTTON,
// Bind the button header to the localizable string of the schema.
"caption": { bindTo: "Resources.Strings.MyButton" },
// Bind the button click handler method.
"click": { bindTo: "onBtnClick" },
"visible": {"bindTo": "isButtonVisible"},
// Setting the location of the button.
"layout": {
"column": 1,
"row": 1,
"colSpan": 2
}
}
}
]/**SCHEMA_DIFF*/
};
});