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.
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.
Hi Jason,
Thank you very much for the help. Looks like there is some syntax error in the code you gave, I am getting the script error for ')'.
Can you resend the corrected code and also point me to the documentation where I can see the same used in the controller not chtml/aspx. Why are you using ")" before })", I tried it but still not working.
I am trying grid.Columns.Add(new UnboundColumn { HeaderText = "Begin Signing",Key = "SignatureStatus",DataType = "string",Template = "<input type=button onclick=fanxyboxOpen(${SignerIndex},${eSign}) value=Start {{if !${SignatureStatus}}} disabled=disabled {{/if}} />" ,Width = "10%" });
And also
grid.Columns.Add(new UnboundColumn { HeaderText = "Begin Signing",Key = "SignatureStatus",DataType = "string",Template = "<input type=button onclick=fanxyboxOpen(${SignerIndex},${eSign}) value='Start' {{if !${SignatureStatus}}} disabled=disabled {{/if}} />" ,Width = "10%" });
I corrected the syntax, thank for your help, Please find the corrected code below:
grid.Columns.Add(new UnboundColumn { HeaderText = "Begin Signing",Key = "SignatureStatus",DataType = "string",Template = "<input type='button' onclick=fanxyboxOpen(${SignerIndex},${eSign}) value='Start' {{if !${SignatureStatus} }} disabled=disabled {{/if}} />",Width = "10%" });
I hooked you the button click event and sending parameters also.
Thank you very much for the help.