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

Turn off lazy loading?

2 Answers 188 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Randy Hompesch
Top achievements
Rank 1
Randy Hompesch asked on 31 Jul 2013, 02:57 PM
Hi,
I seem to be having an issue with client side events and lazy loading.
I have a tv on my layout view as follows:

@Html.Kendo().TreeView().Name("MainMenu").DataSource(dataSource => dataSource
.Read(read => read.Action("Index", "MainMenu"))).DataTextField("MenuText").DataUrlField("Url")

I have code on the server that correctly returns the parts of the tv as necessary.
All is well. My tree displays. When I click on  a parent node a server call is made and the children are show.
Great.

Now the trouble.
I add the following javascript  and when I click on a node I get the alert just fine. However, once, I click ok, I get an error in kendo.all.min.js. Attached is a screenshot of the error.

Thanks ... Ed


function _LayoutOnLoad()
{
    $(function ()
    {
        $("#MainMenu").kendoTreeView({
            select: OnMainMenuSelect
        })
    });
}
function OnMainMenuSelect(e)
{
    alert("Selecting: " + e.node.textContent);
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 01 Aug 2013, 07:07 AM
Hi Randy,


When the following code snippet is executed
$("#MainMenu").kendoTreeView({
    select: OnMainMenuSelect
})

 the TreeView is initialized for a second time and the previous configurations are lost. As a solution, you could either bind to the event in the TreeView configuration.
E.g.
.Events(e => e.Select("OnMainMenuSelect"))
OR
get the data for the TreeView and use the bind method to bind to the event on run-time.
E.g.
var tree = $("#MainMenu").data("kendoTreeView");
tree.bind("select", function(e){
    //custom logic
});

I hope that this information was helpful for you. I wish you a great day!

 

Regards,
Dimiter Madjarov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Randy Hompesch
Top achievements
Rank 1
answered on 01 Aug 2013, 12:19 PM
Fantastic! That one really had me stuck.
Thank you very much!
Ed
Tags
TreeView
Asked by
Randy Hompesch
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Randy Hompesch
Top achievements
Rank 1
Share this question
or