Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
495
disable button in a column depending on the Status of a check box in another column
posted

Hi,

I am using MVC igHierarchicalGrid v2014.1, I want to enable and disable the button in one of the column in the grid depending upon the status of another column.

Eg:

Controller Code :  grid.Columns.Add(new UnboundColumn { HeaderText = "Begin Signing",Key = "Start",DataType = "string",Width = "10%",FormatterFunction = SetSignStatus(" + $(SignatureStatus) + " )});

grid.Columns.Add(new GridColumn() { HeaderText = "Status",Key = "SignatureStatus",DataType = "bool",Width = "5%",Format = "checkbox" });

As you see, I want to disable the button depending on the Status key.
private static string SetSignStatus(string signerStatus)
      {
          var sb = new StringBuilder();
          sb.Append(" function(obj){");
          sb.Append(" if (obj.SignatureStatus){return '<input type= button   value=Start />';}");
          sb.Append(" else if  (!obj.SignatureStatus){ return '<input type=button  disabled=disabled value=Start />';} ");
          sb.Append("} ");
          return sb.ToString();
      }
Unfortunately, I am not understanding the way I can send the "row" so that I can check something like row.SignatureStatus or just the SignatureStatus.
Also if you observe I am using FormatterFunction = SetSignStatus(" + $(SignatureStatus) + " )},
this syntax is not working, the parameter in SetSignStatus(string signerStatus) is return a value as "$(SignatureStatus)".

Your help is much appreciated.
Parents
  • 8421
    posted

    Hello,

    For something like this a template on your unbound column may be a better approach.  The code to do this would like something like this:

    grid.Columns.Add(new UnboundColumn { HeaderText = "Begin Signing",Key = "Start",DataType = "string",Width = "10%", Template = "<input type=button value='Start' {{if !${SignatureStatus} }} disabled=disabled {{/if}}")});

    The {{if}} block in there uses the Ignite UI templating engine to pull the value from the SignatureStatus field and check to see if it is false.  If it is, then it applies the disabled attribute.

    Please let me know if this meets your requirements or if I may be of any other assistance.

Reply Children