Children null vs empty

2 posts, 0 answers
  1. Patrick
    Patrick avatar
    64 posts
    Member since:
    Jun 2008

    Posted 03 Oct 2019 Link to this post

    If the children property is not null then the expand children arrow will display.

    It displays even if the children is an empty array.

    This may be a feature but seems more like a bug to me.

    <TelerikMenu Data="@MenuItems" Orientation="MenuOrientation.Vertical"

    public class MenuItem
        public string Text { get; set; } = "";
        public string Url { get; set; } = "";
        public string Image { get; set; } = "";
        public MenuItem[] Children { get; set; } // Arrow will show on all items if: = Array.Empty<MenuItem>();
  2. Marin Bratanov
    Marin Bratanov avatar
    5070 posts

    Posted 07 Oct 2019 Link to this post

    Hello Patrick,

    You can set the HasChildren property to override that if you want:

    On null children vs empty collection - this is needed for the lazy loading (load on demand). Initially, an item may not have child items, but it may have to show an expand arrow so the user has a way to load them. The HasChildren field, again, allows you to override that.
    You can find examples of how empty collections must provide you with expand arrows in this demo: - if the expand arrows are not there, you can't see the details. Another example is available in the documentation that shows using the HasChildren field to control this, and using null fields:


    Marin Bratanov
    Progress Telerik

     UI for Blazor
Back to Top