Add conditional button into the active row of detail
Hi all,
Further to the thread below, is it possible to make a button added to the active row of a detail conditional?
Add button into the active row of detail | Community Creatio
I want to make the button enabled on a certain condition but when I add the enabled and visible values to the Diff of the datagrid, I get no result (tried passing "enabled": false to check it wasn't an issue with the CanSplitFlights method)
define("UsrFlightsDetail", ["ProcessModuleUtilities"], function(ProcessModuleUtilities) { return { entitySchemaName: "UsrFlights", details: /**SCHEMA_DETAILS*/{}/**SCHEMA_DETAILS*/, diff: /**SCHEMA_DIFF*/[ { "operation": "merge", "name": "DataGrid", "parentName": "Detail", "propertyName": "items", "values": { "activeRowActions": [], "activeRowAction": {"bindTo": "onActiveRowAction"} } }, { "operation": "insert", "name": "DataGridActiveRowSplitFlights", "parentName": "DataGrid", "propertyName": "activeRowActions", "values": { "className": "Terrasoft.Button", "style": Terrasoft.controls.ButtonEnums.style.BLUE, "caption": "Split flights", "tag": "SplitFlights", "visible": true, "enabled": CanSplitFlights } } ]/**SCHEMA_DIFF*/, methods: { CanSplitFlights: function() { var FlightTypeId = this.getActiveRow().get("UsrFlightType"); var FlightTypeValue = FlightTypeId && FlightTypeId.value; if (FlightTypeValue == '3a0d3b1b-9af5-472a-bac9-e785500ac4e9') { return true; } return false; }, onActiveRowAction: function(SplitFlights) { switch (SplitFlights) { case "SplitFlights": this.onSplitFlights(); break; default: break; } }, onSplitFlights: function(){ ProcessModuleUtilities.executeProcess({ sysProcessName: "UsrSplitFlights", parameters: { FlightId: this.getActiveRow().get("Id") } }); },
Like
I've done some hacky options that sort of worked manipulating the button elements in the dom on row click, but I've never been able to have it work binding an attribute to the visible/enabled of the row buttons and change row by row. That's never worked for me. Instead I typically do a check in the code that executes on click to let the user know if it's not available for the row. I'd love to know if there's some way for this to work, but from experience it doesn't work.
I've done some hacky options that sort of worked manipulating the button elements in the dom on row click, but I've never been able to have it work binding an attribute to the visible/enabled of the row buttons and change row by row. That's never worked for me. Instead I typically do a check in the code that executes on click to let the user know if it's not available for the row. I'd love to know if there's some way for this to work, but from experience it doesn't work.
Ryan Farley,
Thanks Ryan. I'll call it quits then and add a check on click.
Honestly, it's more of an aesthetic requirement than a functional one. Ideally I won't offer the user a button that they can't click.