Kendo Grid - In Column.Bound - Client Template passing function with params not working

2 posts, 0 answers
  1. Bhanu
    Bhanu avatar
    1 posts
    Member since:
    Jul 2018

    Posted 12 Jul 2018 Link to this post

    Hi All,

    I am working on Telerik Kendo Grid. The scenerio is :

    Passing function with parameter in columns.bound client template, but getting the below error

    "Uncaught ReferenceError: InvoiceStatus is not defined"

    Note : With out giving parameter in the function its working fine.

    Please verify the code below :

     <script id="template" type="text/kendo-tmpl">
            @(Html.Kendo().Grid<NH.Accounts.Models.ProviderPaymentMemberLevel>() //<a onclick='alert(\"#: encode(OrderName) #\")' href='\\#'>#= OrderName #</a>  ClientTemplate("#=someFuntion(ExecutionStartDateTime)#");
                                        .Name("grid_#=ProviderId#")
                                        .HtmlAttributes(new { style = "backgroud-color:#27326e " }) //"<a onclick=\"showOrderDetail('#= OrderName #')\" href='\\#'>#= OrderName #</a>"
                                        
                                        .Columns(columns =>
                                         {
                                             //"#if(TotalBalance > 0) {#" + "<span style='padding-right: 10px;'>$ #=TotalBalance#</span><input type='checkbox' 'checked=checked' class='master-pay-checkbox' data-providerid='#=ProviderId#'></input>#}#"
                                             columns.Bound(o => o.InvoiceStatus).Filterable(false).Width(10).ClientTemplate("#= GetInvoiceStatusColor(InvoiceStatus) #").HtmlAttributes(new { style = "text-align: left" });

     

    Thanks

    Bhanu

  2. Georgi
    Admin
    Georgi avatar
    684 posts

    Posted 16 Jul 2018 Link to this post

    Hello Bhanu,

    I have investigated the provided configuration and noticed that the grid is within a template. I assume that this grid is used as a detail template in another parent grid.

    Therefore it is necessary to escape the # literals in order to evaluate them in the context of the child grid.

    e.g.

    columns.Bound(o => o.InvoiceStatus).Filterable(false).Width(10).ClientTemplate("\\#= GetInvoiceStatusColor(InvoiceStatus) \\#").HtmlAttributes(new { style = "text-align: left" });
     

    Regards,
    Georgi
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top