This is a migrated thread and some comments may be shown as answers.

Call method from template using template value as parameter

1 Answer 233 Views
Templates
This is a migrated thread and some comments may be shown as answers.
Cool Breeze
Top achievements
Rank 1
Cool Breeze asked on 04 Nov 2014, 02:49 AM
Hello,

I'm trying to convert the following element of a dynamic table into a template for a list view but am not sure how to go about passing the template value to the function in order to get the correct display value.

Here is the HTML version:

<tr>
    <td colspan="4" style="padding-left:10px; font-weight:bold; font-size:larger">
        @{
            var orderStatus = EnumHelper<OrderStatuses>.GetDisplayValue(order.OrderStatus);
        }
        @orderStatus
    </td>
</tr>

My issue is getting the OrderStatus passed into the EnumHelper method.

<tr>
    <td colspan="4" style="padding-left:10px; font-weight:bold; font-size:larger">
        @{
            var orderStatusDescription = EnumHelper<OrderStatuses>.GetDisplayValue(#=OrderStatus#);
        }
        @orderStatusDescription
    </td>
</tr>

What would the syntax be for this type of scenario or is it not supported (or is there a better way)?

Thanks!




1 Answer, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 05 Nov 2014, 10:05 AM
Hello Joe,

the helper method is executed on the server, and the #= # interpolation occurs on the client. You should port your helper methods to the client, so that you can do something like this:

#= getDisplayValue(OrderStatus) #.  

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Templates
Asked by
Cool Breeze
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Share this question
or