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

Treeview child item not binding

1 Answer 86 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Anil
Top achievements
Rank 1
Anil asked on 08 Feb 2014, 12:25 AM
Hi,

Can anyone help me on how to solve this issue?  I was able to see the parent nodes but not the children.  

Json result:

[{"PartNo":"1KK-21BD","HasChild":true,"_items":[{"ChildPartNo":"9003"},{"ChildPartNo":"7043"},{"ChildPartNo":"4036"},{"ChildPartNo":"9023"},{"ChildPartNo":"9040"}]}]

Below is my code:

@(Html.Kendo().TreeView()
    .Name("treeview")
    .HtmlAttributes(new {@class="demo-section" })
    .LoadOnDemand(false)
    .DataTextField("PartNo")
    .DataSource(dataSource => dataSource
        .Read(read => read
            .Action("Search", "Home").Data("GetInfo")
        )
       
    )
)




 function btnSearch_click() {
   GetInfo();
 }


 function GetInfo() {
        
        $.ajax({
            type: "POST",
            dataType: "json",
            contentType: 'application/json; charset=utf-8',

            data: JSON.stringify({
                PartNo: $('#txtNo').val()
            }),
            url: "@Url.Action("Search", "Home")",

            success: function (result) {
                debugger;
                  var dataSource = new kendo.data.HierarchicalDataSource({
                    data: result,
                    schema: {
                        model: {
                            PartNo: 'PartNo',
                            children: '_items',
                            hasChildren: 'HasChild'
                        }
                    }
                });

                $("#treeview").data("kendoTreeView").dataSource.data(dataSource.options.data);
            }
        })




Thanks for your help!!

1 Answer, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 11 Feb 2014, 05:19 PM
Hello Anil,

From the provided information it is not possible to determine what is causing this issue. Would it be possible to extract a runnable sample? We will be more than happy to take a look at.

Thank you in advance for your cooperation.

Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
Anil
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or