ListView in text/x-kendo-template

2 posts, 0 answers
  1. Yilang
    Yilang avatar
    12 posts
    Member since:
    Jan 2016

    Posted 06 Sep Link to this post

    <script type="text/x-kendo-template" id="template">
        <div id="details-container">
            <p>标题:#=Title#</p>
            <p>内容:#=Content#</p>
            <p>状态:#=Passstatus#</p>
            <p>提交人:#=SendPerson#</p>
            <p>提交时间:#=SendDate#</p>
            <div class="demo-section k-content wide">
                @(Html.Kendo().ListView<txlcinfo.EnSystem.ViewModels.QuImgsViewModel>()
                    .Name("imglistView")
                    .TagName("div")
                    .ClientTemplateId("img_template")
                    .DataSource(dataSource =>
                    {
                        dataSource.Read(read => read.Action("img_Read", "UserDiscuss", new { sid = "#=ID#" }));
                        dataSource.PageSize(3);
                    })
                    .Pageable()
                )
            </div>
        </div>
    </script>

    That's my code,but it has problem,like this:

    Uncaught Error: Invalid template:'
        <div id="details-container">
            <p>标题:#=Title#</p>
            <p>内容:#=Content#</p>

            



            <p>状态:#=Passstatus#</p>
            <p>提交人:#=SendPerson#</p>
            <p>提交时间:#=SendDate#</p>
            <div class="demo-section k-content wide">
                <div id="imglistView"></div><div class="k-pager-wrap" id="imglistView_pager"></div><script>
    jQuery(function(){jQuery("#imglistView").kendoListView({"dataSource":{"type":(function(){if(kendo.data.transports['aspnetmvc-ajax']){return 'aspnetmvc-ajax';} else{throw new Error('The kendo.aspnetmvc.min.js script is not included.');}})(),"transport":{"read":{"url":"/Admin/UserDiscuss/img_Read?sid=#=ID#"},"prefix":""},"pageSize":3,"page":1,"total":0,"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"ID":{"type":"string"},"imgpath":{"type":"string"}}}}},"template":kendo.template(jQuery('#img_template').html()),"pageable":{"autoBind":false,"buttonCount":10,"messages":{"display":"显示条目 {0} - {1} 共 {2}","empty":"没有可显示的记录。","page":"页","of":"共 {0}","first":"首页","previous":"前页","next":"后页","last":"末页","refresh":"刷新","morePages":"更多页"},"pagerId":"imglistView_pager"}});});
    ' Generated code:'var $kendoOutput, $kendoHtmlEncode = kendo.htmlEncode;with(data){$kendoOutput='\n    <div id="details-container">\n        <p>标题:'+(Title)+'</p>\n        <p>内容:'+(Content)+'</p>\n\n        \n\n\n\n        <p>状态:'+(Passstatus)+'</p>\n        <p>提交人:'+(SendPerson)+'</p>\n        <p>提交时间:'+(SendDate)+'</p>\n        <div class="demo-section k-content wide">\n            <div id="imglistView"></div><div class="k-pager-wrap" id="imglistView_pager"></div><script>\n\tjQuery(function(){jQuery("';imglistView").kendoListView({"dataSource":{"type":(function(){if(kendo.data.transports['aspnetmvc-ajax']){return 'aspnetmvc-ajax';} else{throw new Error('The kendo.aspnetmvc.min.js script is not included.');}})(),"transport":{"read":{"url":"/Admin/UserDiscuss/img_Read?sid=;$kendoOutput+='=ID';"},"prefix":""},"pageSize":3,"page":1,"total":0,"serverPaging":true,"serverSorting":true,"serverFiltering":true,"serverGrouping":true,"serverAggregates":true,"filter":[],"schema":{"data":"Data","total":"Total","errors":"Errors","model":{"fields":{"ID":{"type":"string"},"imgpath":{"type":"string"}}}}},"template":kendo.template(jQuery(';$kendoOutput+='img_template\').html()),"pageable":{"autoBind":false,"buttonCount":10,"messages":{"display":"显示条目 {0} - {1} 共 {2}","empty":"没有可显示的记录。","page":"页","of":"共 {0}","first":"首页","previous":"前页","next":"后页","last":"末页","refresh":"刷新","morePages":"更多页"},"pagerId":"imglistView_pager"}});});\n';}return $kendoOutput;'

  2. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 08 Sep Link to this post

    Hello Yilang,

    It seems that you are trying to create a server-side component within the kendo template. Therefore, you can try using the .ToClientTemplate() method similar to this live sample:
    http://demos.telerik.com/aspnet-mvc/grid/hierarchy

    I hope this will prove helpful.

    Regards,
    Eyup
    Telerik by Progress
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top