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

Help (Parameter (children) in tree view)

4 Answers 46 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Butter
Top achievements
Rank 1
Butter asked on 22 Jul 2013, 11:18 AM
pl help me,.
I'm having difficulty in parameter in children tree view.
I don't know how to do it.
Everyone pl hepl me.
My code here below:
**********************************************************************
 function populateTreeView(){
       var url = "/Home/Get_Catagory_Menu";
        var dataSource = new kendo.data.HierarchicalDataSource({
            transport: {
                read: {
                    url: url,
                    dataType: "json",
                    data: { 'flag': 1, cat_id=????  ==> it here }
                }
            },
            schema: {
                model: {
                    id: "cat_id",
                    text: "cat_name",
                    expanded: false,
                    hasChildren:"haschildren",
                    children:{
                        transport: {
                            read: {
                                url: url,
                                dataType: "json",
                                data: { 'flag': 2 , cat_id=????  ==> it here}
                            }
                        },
                        schema: {
                            model: {
                                id: "prd_id",
                                text: "prd_name",
                                hasChildren: false
                            }
                        }
                   }
                },
            }
        });
//        function onExpand(e){
//            console.log(this.text(e.node));
//        }
        $("#treeview").kendoTreeView({
          // autoBind: false,
            dataSource: dataSource,
            dataTextField: ["cat_name","prd_name"],
          // expand: onExpand,
       });
   }
    $(document).ready(function () {
        populateTreeView();
    })
********************************************

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 24 Jul 2013, 08:41 AM
Hello Butter,

The cat_ID of the node that you are expanding will be automatically send to the server. Check the network tab of you browser to see how it is send to the server when playing with the following demo:

http://demos.kendoui.com/web/treeview/remote-data.html

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Butter
Top achievements
Rank 1
answered on 25 Jul 2013, 06:54 AM
Thank Petur Subev for helping me
0
Dan
Top achievements
Rank 1
answered on 22 Nov 2013, 06:54 PM

My data structure is bit different.
Organization [OrgID, OrgName]
     Group [GroupID, OrgID, GroupName]
         Members
            [MembersID, GroupID, MemberName]
    Event
     [EventID, OrgID, EventName] 

 I struggled for a while to represent this structure in treeview.
Questions
 1) Can somebody help? 
       Should I use sql view to produce flat data?
       Or  I can recursively fetch children data given parent ID?
 2) I have basic webapi services working to return Json
      Do I need jsonp callback function to do recursive call to get children datat?


Many thanks.
0
Petur Subev
Telerik team
answered on 25 Nov 2013, 08:17 AM
Hello Dan,

I am afraid that the data structure that you demonstrated cannot be represented by the TreeView, each level of the hierarchy should be with the same strucutre like demonstrated in this demo.

Either make your data flat or parse your models to always have a field with the same name that can be used as dataTextField.

Kind Regards,
Petur Subev
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
Butter
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Butter
Top achievements
Rank 1
Dan
Top achievements
Rank 1
Share this question
or