Kendo Grid DetailTemplate Setting Error

1 Answer 26 Views
Grid
Morris
Top achievements
Rank 1
Morris asked on 11 Jan 2024, 03:14 AM | edited on 11 Jan 2024, 03:14 AM

excute me, when i use kendo grid detailtemplate feature, i have some trouble. how can i fix it?

my source:

<div class="panel-collapse collapse show" id="collapse1" aria-expanded="true">
        @(
Html.Kendo().Grid(Model.UserRoleList.Value)
    .Name("gridRoles")
    .Scrollable()
    .Columns(columns =>
    {
        columns.Bound(c => c.RoleName).Width(130);
    })
    .Height(250)
    .DataSource(d => d.Custom()
                    .Type("aspnetmvc-ajax")
                    .Transport(t => t.Read(r => r.Url($"{_config.Value.AuthSettings?.ApplicationName ?? ""}/SystemManagement/UserPermission/View?handler=Paged&userId={Model.UserInfo.UserId}")))
                    .Batch(true)
                    .Schema(s => s.Model(
                        m => {
                            m.Id(p => p.RoleCode);
                        }
                    ).Data("Data"))
    )
    .ClientDetailTemplateId("templateGrp")
    .Deferred()
)

        <script id="templateGrp" type="text/x-kendo-template">
            <div>RoleCode: 123</div>
        </script>

        <script nonce="@_config.Value.AppSettings.CspNonce">
            @Html.Kendo().DeferredScripts(false);
        </script>

 

 

and feedback error:

Error: Invalid template:'
            <div>RoleCode: 123<//div>
        ' Generated code:'var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='\n            <div>RoleCode: 123<//div>\n        ';}return $kendoOutput;'

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 15 Jan 2024, 02:08 PM

Hi Morris,

Thank you for the code snippet and the details provided.

Could you please remove the deferring configuration and script, and try to run the code?

Here is an example:

<div class="row">
    <div class="col-12">
        @(Html.Kendo().Grid<TelerikMvcApp4.Models.OrderViewModel>()
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(p => p.OrderID).Filterable(false);
                columns.Bound(p => p.Freight);
                columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}");
                columns.Bound(p => p.ShipName);
                columns.Bound(p => p.ShipCity);
            })
            .Pageable()
            .Sortable()
            .Scrollable()
            .Filterable()
            .HtmlAttributes(new { style = "height:550px;" })
            .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(20)
                .Read(read => read.Action("Orders_Read", "Grid"))
            )
            .ClientDetailTemplateId("templateGrp")
        )
    </div>
</div>

<script id="templateGrp" type="text/x-kendo-template">
    <div>RoleCode: 123</div>
</script>
The result:

Give a try to the approach above and let me know if it achieves the desired result.

Kind Regards,
Anton Mironov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.
Tags
Grid
Asked by
Morris
Top achievements
Rank 1
Answers by
Anton Mironov
Telerik team
Share this question
or