Hiding custom button for active record in detail based on some condition of record's field

diff: /**SCHEMA_DIFF*/[
         {
            
       "operation": "merge",
       "name": "DataGrid",
       "values": {
               "activeRowAction": {bindTo: "onActiveRowAction"},
               "activeRowActions": [
                       {
                               "className": "Terrasoft.Button",
                               "style":this.Terrasoft.controls.ButtonEnums.style.BLUE,
                               "markerValue": "myButtonAction",
                               "tag": "myAction",
                               "caption": "View image",
                               "enabled": false,
                               "visible":{bindTo: "IsButtonVisible"},
                         
                                 
                       }
               ],
               // "visible": {"bindTo": "isButtonVisible"},
               
       }
}
       ]/**SCHEMA_DIFF*/,
        methods: {
            isButtonVisible: function()
            {
           console.log("hello");
           const activerow= this.get("ActiveRow");
           if(activerow)
            {
 
              var msg= this.getActiveRow().get("UsrMessage") ;
               if(msg==="hello"){return false;}
               
            }
           return true;
             
         }
       }
    };

I tried adding button, and when giving visible:true, it is working fine, now i want to hide that button from some records of detail based on some condition so i bind it with the function, but it is not working, the function is not getting called/executed, when i am doing it at grid level then it is working fine, but not working on button, is there something am i missing or doing wrong, i even tried it using attribute and setting it's value in the function

Like 0

Like

1 comments

I've never been successful with binding values in ActiveRowActions to attributes to change them after render. They don't seem to have the same bindings as other view model elements do. The only way I've been able to get this to work is to modify the dom elements on row select to manipulate, which is a bit hacky. Alternatively, just add logic to the button click to validate if the action can be performed or not, which isn't ideal either.

Ryan

Show all comments