How can I include HTML from my model into a listview via the template?

3 posts, 1 answers
  1. Mark
    Mark avatar
    4 posts
    Member since:
    Nov 2010

    Posted 14 Mar 2013 Link to this post

    @* Html contains html string from model *@

    <script id="news-item-template" type="text/x-kendo-template">
        <div class="wrapper">
            <figure class="img-indent indent-top1 img-indent-none-mp">
                <img src="${imgPath}" alt="" />
            </figure>
            <div class="extra-wrap clear-ml">
                    ${Html}
            </div>
            <div class="edit-buttons">
                <a class="k-button k-button-icontext k-edit-button" href="\\#"><span class="k-icon k-edit"></span>Edit</a>
                <a class="k-button k-button-icontext k-delete-button" href="\\#"><span class="k-icon k-delete"></span>Delete</a>
            </div>
        </div>
    </script>

        <div class="container_12">
            <div class="wrapper">
                <div class="grid_7 left">
                    <div class="box">
                    <h3>Latest News</h3>

                        <div class="k-toolbar k-grid-toolbar">
                            <a class="k-button k-button-icontext k-add-button" href="#"><span class="k-icon k-add"></span>Add new record</a>
                        </div>

                        @(Html.Kendo().ListView<MyClub.Models.xtbl_NewsItem>(Model)
                            .Name("listView")
                            .TagName("div")
                            .ClientTemplateId("news-item-template")
                            .DataSource(dataSource => dataSource
                                .Model(model => model.Id("Id"))
                                .PageSize(3)
                                .Create(create => create.Action("NewsCreate", "Home"))
                                .Read(read => read.Action("NewsRead", "Home"))
                                .Update(update => update.Action("NewsUpdate", "Home"))
                                .Destroy(destroy => destroy.Action("NewsDestroy", "Home"))
                            )
                            .Pageable()    
                            .Editable()
                        )

                    </div>
                </div>
            </div>
        </div>


  2. Answer
    Mark
    Mark avatar
    4 posts
    Member since:
    Nov 2010

    Posted 14 Mar 2013 Link to this post

    <div class="extra-wrap clear-ml">
              #= Html #
    </div>

  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 18 Mar 2013 Link to this post

    Hi Mark,


    I am glad to hear that you solved the problem. If you need additional resources, you could take a look at our Template demos or the following pages from the documentation:

    Kendo UI Templates Overview
    Load Templates From External Files

    Wish you a great day! 

    Regards,
    Dimiter Madjarov
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top