Call method from template using template value as parameter

2 posts, 0 answers
  1. Cool Breeze
    Cool Breeze avatar
    44 posts
    Member since:
    Jan 2014

    Posted 03 Nov 2014 Link to this post

    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!




  2. Petyo
    Admin
    Petyo avatar
    2438 posts

    Posted 05 Nov 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
Back to Top