Hello all, I have a custom detail in Projects. I have added a button to it, but only want it to show if certain conditions are met for that row. Button will be tied to a business process. I can manual set "visible": false/false. But can't set vars anywhere for that.
What is the best way to do it?
{ "operation": "insert", "name": "DataGridActiveRowSomeButton", "parentName": "DataGrid", "propertyName": "activeRowActions", "values": { "className": "Terrasoft.Button", "style": Terrasoft.controls.ButtonEnums.style.BLUE, "caption": "Send Invoice", "tag": "someButton", "visible": true, "enabled" : false }
onActiveRowAction: function(buttonTag) { switch (buttonTag) { case "someButton": this.onSomeButtonClicked(); break; default: break; } //end switch }, onSomeButtonClicked: function() { var message = ""; message += "hello world! "; message += this.getActiveRow().get("Usrpaymentamount"); this.showInformationDialog(message); }
Like
Hello Keith,
Please try to use the below approach:
1. Bind the visibility property to a function:
{
"operation": "insert",
"name": "DataGridActiveRowSomeButton",
"parentName": "DataGrid",
"propertyName": "activeRowActions",
"values": {
"className": "Terrasoft.Button",
"style": Terrasoft.controls.ButtonEnums.style.BLUE,
"caption": "Send Invoice",
"tag": "someButton",
"visible": { "bindTo": "isButtonVisible" },
"enabled": false
}
}
2. Add a function to determine button visibility and add your conditions. For example, check if a certain filed value in the active row meets your condition and return true to make the button visible if the condition is met, or false to hide it. :
isButtonVisible: function() {
var conditionMet = this.getActiveRow().get("SomeField") === "SomeValue";
return conditionMet;
}
Hope it helps!
Best regards,
Anastasiia
Thank you for the reply, this issue is where do you put "isButtonVisible" It is not working with
onActiveRowAction
Hi,
If I understand your concern correctly, "isButtonVisible" should not be placed inside the "onActiveRowAction" function. Instead, it should be defined as a separate function in the same context or scope where your button configuration is defined.
Please let me know if the issue persists!
Best regards,
Anastasiia
Anastasiia Zhuravel,
Thank you so much for your help. I have tried that and whenever a function is used it will not show. This is what I added
{ "operation": "insert", "name": "DataGridActiveRowSomeButton", "parentName": "DataGrid", "propertyName": "activeRowActions", "values": { "className": "Terrasoft.Button", "style": Terrasoft.controls.ButtonEnums.style.BLUE, "caption": "Send Invoice", "tag": "someButton", "visible": { "bindTo": "isbutactive" }, "enabled" : false } } ]/**SCHEMA_DIFF*/, methods: { isbutactive: function() { if ( this.getActiveRow().get("UsrPaymentSent") == false) { return true; }else{ return false; } },
Even if I do this it will not show.
isbutactive: function() {
if ( 1==1) {
return true;
}else{
return false;
}
},
All, Looks like I can not find the correct function to check the data once it is loaded in the detail, I have tried onRender, onGridDataLoaded, Init and others, but it us unable to read the data. None of the rowchange functions I find seem to work either. Any ideas?
Thank you