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

TreeList does not display hierarchical data even though datasource is set

3 Answers 445 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 12 Sep 2015, 03:06 PM

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?

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 15 Sep 2015, 02:22 PM
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
0
Thanh
Top achievements
Rank 1
answered on 17 Dec 2015, 10:50 AM

Hi,

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

 Thanks

0
Viktor Tachev
Telerik team
answered on 17 Dec 2015, 02:40 PM
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
Tags
TreeList
Asked by
Tim
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Thanh
Top achievements
Rank 1
Share this question
or