Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Jasper van den Bergh 4 posts 84 karma points
    Jul 11, 2019 @ 10:32
    Jasper van den Bergh

    Binding a collection of PublishedModels to a Telerik/Kendo Grid

    I have a collection of NewsItem models that I would like to bind to a Telerik Grid in my Umbraco site.

    Here's the code:

    var selection = Umbraco.Content(Guid.Parse("c79a20b7-4c99-42df-b262-558ab15f01c4"))
                    .OrderByDescending(x => x.CreateDate).OfType<NewsItem>();

    And then:

                .Pageable(pager => pager.AlwaysVisible(false))
                .Columns(columns =>
                    columns.Template(e => { }).ClientTemplate(" ").Width("auto").HeaderHtmlAttributes(new { style = "display:none;" });
                    // Simplified for readability
                    "#: Titel #" +
                    "#: Url #" +
                    "#: Teaser #"
                .DataSource(dataSource => dataSource

    This code will give me an error: A circular reference was detected while serializing an object of type 'Umbraco.Core.Models.PublishedContent.PublishedContentType'. Probably because of the Children ad Parent properties.

    I have fixed this by copying only the required properties to an anonymous type and then bind that to the grid. But I was wondering if there is a more elegant way of doing this?

Please Sign in or register to post replies

Write your reply to: