IE TreeView findByUid Bug\Error

5 posts, 1 answers
  1. Coty
    Coty avatar
    41 posts
    Member since:
    Jun 2014

    Posted 29 Sep 2015 Link to this post

    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.

     

     

     

  2. Answer
    Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 01 Oct 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Coty
    Coty avatar
    41 posts
    Member since:
    Jun 2014

    Posted 01 Oct 2015 in reply to Alexander Popov Link to this post

    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!
  5. Coty
    Coty avatar
    41 posts
    Member since:
    Jun 2014

    Posted 01 Oct 2015 in reply to Coty Link to this post

    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.

     

  6. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2284 posts

    Posted 06 Oct 2015 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready