TreeList does not display hierarchical data even though datasource is set

4 posts, 0 answers
  1. Tim
    Tim avatar
    8 posts
    Member since:
    Jul 2008

    Posted 12 Sep 2015 Link to this post

    I have a ​TreeList that simply does not display the data it is receiving through the remote binding.

    I can confirm (via Fiddler AND the KendoUI for Chorme browser extension) that the JSON data received is loaded and does contain data. However, the tree list does not display it.

    I can't seem to figure out why. Please see attached images.

    I also tried turning AutoBind ON/OFF, ServerOperation ON/OFF. Nothing helps. I don't see what's wrong with it.

     

    View:

                @(Html.Kendo().TreeList<Web.Models.LevelViewModel>()
                      .Name( "treelist1" )
                      .Columns( columns =>
                      {
                          columns.Add().Field( e => e.Name );
                      } )
                      .DataSource( dataSource => dataSource
                           .Read( read => read.Action( "Load", "Business" } ) )
                           .ServerOperation( false )
                           .Model( m =>
                           {
                               m.Id( f => f.Id );
                               m.ParentId( f => f.ParentId );
                               m.Expanded( true );
                               m.Field( f => f.Name );
                           } )
                      )
                      )

    Controller:

                var result = controllerService.BuildLevel​s( 1 );
                return Json( result.ToTreeDataSourceResult( request,
                    e => e.Id,
                    e => e.ParentId
                    ), JsonRequestBehavior.AllowGet );

     Model:

        public class LevelViewModel : ViewModelBase
        {
            public int Id { get; set; }
            public int? ParentId { get; set; }
            public string Name { get; set; }
            public int FunctionId { get; set; }
            public int LevelId { get; set; }
        }

      

     

    Can you please help?

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 15 Sep 2015 Link to this post

    Hello Tim,


    I noticed that you have opened a support ticket for the same issue. I suggest to continue the conversation there. After the issue is resolved you can share the resolution in this thread. This can be helpful to anyone facing similar issue.

    On a side note, please avoid submitting duplicate threads. Thus, we will be able to keep better track of your support history and provide answers faster.


    Regards,
    Viktor Tachev
    Telerik
    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
  4. Thanh
    Thanh avatar
    2 posts
    Member since:
    Jan 2015

    Posted 17 Dec 2015 Link to this post

    Hi,

     I am facing similar issue. Would you mind sharing your resolution for this?

     Thanks

  5. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 17 Dec 2015 Link to this post

    Hi,

    In this case the issue was that the TreeList was not able to determine which items are root nodes. The widget does that by checking the ParentId field. The default value for it is null. However, this can be configured via the DefaultValue method.


    m.ParentId(m => m.ParentId).DefaultValue(123); // root items will have ParentId = 123



    Regards,
    Viktor Tachev
    Telerik
    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready