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

adding child node to selected node

4 Answers 659 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Eugeni
Top achievements
Rank 1
Eugeni asked on 26 Mar 2021, 07:59 AM

Hello. 

I modifed an example from demo. To add one child node to selected node.

https://dojo.telerik.com/uhUnukOJ/3

Left side is copy from demo, right side other simple version.

Right side add only to the root. And left side works strange.

Second. I have config a hierarhicalDataSource

var treeData = new kendo.data.HierarchicalDataSource({
            transport: {
                read: {
                    url: "api/ui/UIData/folders",
                    contentType: "application/json",
                    dataType: "json",
                    data:
                        {
                            id_hierarchy: 1
                        }
                }              ,
             

                requestEnd: function (e)
                {
                    //check the "response" argument to skip the local operations
                    console.log(e);
                }
            }
        });

It loads root nodes. But does not show any children nodes after loading. requestEnd does not fire too.

 

4 Answers, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 31 Mar 2021, 07:45 AM

Hello Eugeni,
Thank you for your inquiry.

I am currently working on a sample Dojo with a possible solution. However I am going to need some additional time to make it ready. Then I will contact you as soon as possible.

Thank you for your patience in advance.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Stoyan
Telerik team
answered on 31 Mar 2021, 05:19 PM

Hi Eugeni,
Thank you for your patience.

To append an item to the child of the selected node use the jQuery object instead of the DOM element:

 var treeview = $("#treeview-right").data("kendoTreeView");
 treeview.append({ subCategoryName: "selected" }, $(e.node));

 

I have applied this to the Dojo you have shared.

To properly configure the remote dataSource define a schema that determines the hierarchy of the data as shown in the TreeView's Binding to remote data Demo.

 Additionally, depending on your server configuration getting the data from a remote source different than the current host can result in CORS policy conflicts. To avoid this set the dataType:"jsonp".

var serviceRoot = "https://demos.telerik.com/kendo-ui/service";
                    homogeneous = new kendo.data.HierarchicalDataSource({
                        transport: {
                            read: {
                                url: serviceRoot + "/Employees",
                                dataType: "jsonp"
                            }
                        },
                        schema: {
                            model: {
                                id: "EmployeeId",
                                hasChildren: "HasEmployees"
                            }
                        }
                    });

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

 

I hope the above is helpful. Please let me know if additional questions occur.


Regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Eugeni
Top achievements
Rank 1
answered on 01 Apr 2021, 09:13 AM

Hello, Stoyan

Thank you for your reply.

First part of the problem has been solved perfectly!

But about second part there are several questions.

First of all changing to jsonp type does not solve the problem. We meet the same bihavoir as i mensioned early.

It still runs locally and cors enabled but problem still exists. And all queries work perfectly. Child nodes return to the client. See attachment

0
Stoyan
Telerik team
answered on 02 Apr 2021, 03:50 PM

Hi Eugeni,

The encountered behavior is indeed perplexing. Child nodes are returned to the client but the requestEnd event still doesn't fire?

Could you please recreate the experienced behavior in a Dojo sample? This will allow me to better advise you on a solution.

Additionally I don't see an attachment to your previous reply. Make sure you use one of the allowed file types. 

Looking forward to your reply.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
TreeView
Asked by
Eugeni
Top achievements
Rank 1
Answers by
Stoyan
Telerik team
Eugeni
Top achievements
Rank 1
Share this question
or