Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,

Kendo UI experts Please help me..

I am new to Kendo ui. I want to return id of Selected node in kendo treeview in my code.
but it is returning only same node.

On selecting Node i want to return id of selected Node to my code, and in Code i am returning
child elements of that node.

is there any simple way of doing it??

Thanks in advance..

My Code

HTML
<div id="treeview"></div>
                                <script src="~/Scripts/kendo.treeview.min.js"></script>
               						<script>
                                         homogeneous = new kendo.data.HierarchicalDataSource({
										        transport: {
										            read: {
										                url: "@Url.Action("datasourcefortree", "Home")",
													    type: "POST",
													    dataType: "json"
                                                    }
												},
											    schema: {
											        model: {
											            id: "ResourceID",
											            hasChildren: true
											        }
											    }
											});

                                            $("#treeview").kendoTreeView({
                                                dataSource: homogeneous,
                                                dataTextField: "Resource"
                                            });

										</script>





and code of datasourcefortree method of homecontroller


C#
[HttpPost]

        public JsonResult datasourcefortree(int? NodeID)
        {

            FNHSessionManager<resourcemaster> sessionManager = new FNHSessionManager<resourcemaster>(_connString, FNHSessionManager<resourcemaster>.DatabaseType.MsSql);
            FNHRepository<resourcemaster> repository = new FNHRepository<resourcemaster>(sessionManager);
            int nodevalue = 1;

            if (NodeID == null)
            {
                ResourceMaster tree = repository.RetrieveById(nodevalue);
                List<resourcemaster> node = new List<resourcemaster>
            {
                new ResourceMaster
                {
                    ResourceID = tree.ResourceID,
                    Resource=tree.Resource
                }
            };
                return Json(node, JsonRequestBehavior.AllowGet);
            }
            else
            {
                if (NodeID.HasValue)
                {
                    nodevalue = NodeID.Value;
                    IList<resourcemaster> childtreenode = repository.GetAllRecord(nodevalue);
                    return Json(childtreenode, JsonRequestBehavior.AllowGet);

                }
                return (null);
            }


        }
Posted
Updated 27-Sep-13 3:26am
v2
Comments
Suresh Suthar 27-Sep-13 9:27am    
I think you should ask question here http://stackoverflow.com/questions/tagged/kendo-ui
Or
http://www.kendoui.com/forums.aspx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900