This is a migrated thread and some comments may be shown as answers.

Use a template from another file similar to the way that EditorTemplates are sourced

1 Answer 261 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 27 Mar 2019, 07:22 PM

Hello,

When the edit mode is used for other controls, we are given the option to select a template that resides inside of the ~/Views/Shared/EditorTemplates/ folder.I would like to be able to select a template that would be used to display each of the records for this control as well instead of relying on .ClientTemplateId(). Is this currently possible?

For instance, I would like to be able to select the template located at ~/Views/Shared/Templates/ChannelCard.cshtml by doing the following:

@(Html.Kendo().ListView<NotificationSystem.Data.Models.ChannelCard>()
          .Name("channels")
          .TagName("ul")
          .TemplateName("ChannelCard")
          .DataSource(dataSource => dataSource
              .Ajax()
              .Read(read => read.Action("Read", "Channels").Data("bindSearch"))
              .PageSize(20)
          )
          .Pageable()
          .HtmlAttributes(new {@class = "channel-list"})
          .Deferred()
          )

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 01 Apr 2019, 01:22 PM
Hi Adam,

The ListView widget currently supports only client side Kendo templates. Nevertheless, you could extract the content of the template in a separate view and render it within the Kendo template.

e.g.

// ListViewTemplate.cshtml
 
<div class="product">
    <img src="http://placehold.it/120x120&text=image#=ID#" />
    <h3>#:FirstMidName#</h3>
    <p>#:LastName#</p>
</div>
 
// kendo template
 
<script type="text/x-kendo-tmpl" id="template">
    @Html.Partial("ListViewTemplate")
</script>


Regards,
Georgi
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ListView
Asked by
Adam
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or