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

IE TreeView findByUid Bug\Error

4 Answers 75 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Coty
Top achievements
Rank 1
Coty asked on 29 Sep 2015, 01:00 PM
Hi There, I have a treeview that I initialize with a datasource, and on the dataBound event (After the tree finishes loading) I select a node within the tree.  This works in both Firefox and Chrome, but it errors in IE 11.  Here is the code I use to initialize the tree.  I have validated that the code is retrieving the correct UID as a string before it tries to select the node. I Bolded the code below where the issue is occurring.  The Error happens on tree.select(item).
 
     $(treeid).kendoTreeView({
    template: kendo.template($("#treeview-template").html()),
    dataSource: myItems,
    loadOnDemand: false,
    dataTextField: ["Name", "Name"],
    select: onSelect,
    dataBound: function (e) {
        var tree = $(treeid).data('kendoTreeView');
            if (itemId !== 0) {
                //select item based on url
                if ($("#" + itemId).length > 0) {
                    var uid = $("#" + itemId).closest("li").data("uid");
                    if (typeof uid !== 'undefined' && uid !== '') {
                        item = tree.findByUid(uid);
                        tree.select(item);
                        tree.trigger("select", {
                            node: item
                        });
                    }
                }
             }
 
        tree.expand(".k-item");
 
    }
});

 

I attached a JPG of the Error I recieve, and also a JPG of the console.log value of the node that gets returned from the findByUid Method.

 

 

 

4 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 01 Oct 2015, 12:51 PM
Hello Coty,

I was not able to reproduce the issue you described, so if you can share a Dojo or a runnable example where it occurs we would be happy to investigate. I am also not sure why calling the findByUid method is necessary - it seems that you already have found the node by its ID (I assume a template is used to render it). This should be enough to select it, for example: 
tree.select($("#" + itemId).closest("li"))

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Coty
Top achievements
Rank 1
answered on 01 Oct 2015, 02:31 PM
Alexander, thanks for the knowledge.  I excluded the findByUid method and selected the item using the code you provided and I don't receive an error anymore.  Thank You!
0
Coty
Top achievements
Rank 1
answered on 01 Oct 2015, 02:47 PM

One other question, in the same scenario above, I use the dataBound event to indicate that the treeview is done loading.  However the databound Event is fired multiple times.  Is this intended functionality or is the actual tree getting initialized multiple times somehow?  I've attached a JPG with what I see in my console log when my page renders.

 

0
Nikolay Rusev
Telerik team
answered on 06 Oct 2015, 07:14 AM

Hello Coty,

 

TreeView dataBound event is wired to the change event of the DataSource. Thus when you add, remove items the widget will repaint and dataBound will be triggered. It will also be triggered when expand to load child items as the change event from the HierarchicalDataSource will bubble up to the widget.

 

That said it seems expected the behavior which you are observing.

 

Regards,
Nikolay Rusev
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
Coty
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Coty
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or