Query on using the ClientTemplate on Grid with Ajax Binding

4 posts, 1 answers
  1. Uday
    Uday avatar
    17 posts
    Member since:
    Jun 2014

    Posted 11 Sep 2014 Link to this post

    Hi,

    I am trying to call a Html extension helper method  'GetUserFormattedId' from the client template of  a ajax bound grid column. I am trying the format a value of the column.

    I am unable to get it working. Is it allowed to call extension methods in this way? Please advise. 

    @{
              Html.Kendo().Grid<InvoiceSummaryDto>()
              .Name("invoiceAccountingGrid")
              .Columns(columns =>
              {
                  columns.Bound(l => l.Id).ClientTemplate("<a href='" + @Url.Action("Details", "Invoice", new { area = "Accounting" }) + "/#= Id #'" + ">" + @Html.GetUserFormattedId(@"#= Id #") + "</a>").Title("ID");
                  columns.Bound(l => l.ItemsDescription).Title("Description");
                        
              })

    I
  2. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2310 posts

    Posted 12 Sep 2014 Link to this post

    Hi Uday,


    The Html helper cannot be used this way. The reason for this is that it is evaluated on the server side, while the client template is evaluated later on the client side, when the data is bound. This means that the Id value cannot be passed for formatting.

    Regards,
    Dimiter Madjarov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Uday
    Uday avatar
    17 posts
    Member since:
    Jun 2014

    Posted 12 Sep 2014 in reply to Dimiter Madjarov Link to this post

    Hi Dimiter,

    It makes sense now. I ended up writing a Javascript for the same so that it can evaluated on the client side.

    Thanks for your time.
  4. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2310 posts

    Posted 15 Sep 2014 Link to this post

    Hello Uday,


    Thanks for the update. I am glad the information was helpful.

    Have a great day!

    Regards,
    Dimiter Madjarov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top