Hi Team,
We are trying to display Enum Description
for user friendly message. We have some issue on kendo grid template column.
How can we pass the data to the MvcHelperExtensions method. Please
suggest if you have any solution for this.
columns:
[
{ field: "Status", title: "Status", template: kendo.template($("#tempStatus").html())}
]
<script id="tempStatus" type="text/x-kendo-tmpl">
<div>#= Status#</div>// We
are able to see the data
@*<div>@MvcHelperExtensions.GetWorkOrderStatusDescription("Status")</div>*@// We are not sure how to pass this data to a MvcHelperExtensions method.
</script>
My Enum as as below.
public enum WorkOrderStatus
{
[Description("Estimate")]
Estimate = 0,
[Description("Estimate sent")]
SubmittedEstimate = 1,
}
My Extention method is below
public static string GetEnumDescription<TEnum>(TEnum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
if ((attributes != null) && (attributes.Length > 0))
return attributes[0].Description;
else
return value.ToString();
}
We are trying to display Enum Description
for user friendly message. We have some issue on kendo grid template column.
How can we pass the data to the MvcHelperExtensions method. Please
suggest if you have any solution for this.
columns:
[
{ field: "Status", title: "Status", template: kendo.template($("#tempStatus").html())}
]
<script id="tempStatus" type="text/x-kendo-tmpl">
<div>#= Status#</div>// We
are able to see the data
@*<div>@MvcHelperExtensions.GetWorkOrderStatusDescription("Status")</div>*@// We are not sure how to pass this data to a MvcHelperExtensions method.
</script>
My Enum as as below.
public enum WorkOrderStatus
{
[Description("Estimate")]
Estimate = 0,
[Description("Estimate sent")]
SubmittedEstimate = 1,
}
My Extention method is below
public static string GetEnumDescription<TEnum>(TEnum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
if ((attributes != null) && (attributes.Length > 0))
return attributes[0].Description;
else
return value.ToString();
}