[Razor] How to Pre-Load TreePanel and Use Proxy Reader
Gents, Here is my issue and I have searched the forums all day looking for my answer, so now I ask you:
The functionality I need is that a user searches for a phrase and clicks a button. The TreePanel loads the top 2 parents + all nodes in the path that contain the search term. Once the tree is loaded, the user is free to roam around any other folders. Since there are 8,000+ nodes I cannot do them all in one load, I need to pre-load and then use AjaxProxy reader for any additional expanded folders. The pre-load code is working correctly, but as soon as I add a Proxy into the mix, the tree starts trying to immediately get all the children before a user clicks. This causes the tree to break.
How can I load the tree with some initial nodes, as well as allow the user to expand folders to grab node data not included in the original load?
Razor Code
Code:
Html.X().Button()
.ID("btnSearchTerm")
.Text("Search")
.Icon(Icon.Magnifier)
.MarginSpec("0 0 0 5")
.DirectEvents(de =>
{
de.Click.Url = Url.Action("GetTree", "Khalix", new { Area = "CARMA" });
}
Code:
Html.X().TreePanel()
.ID("treeKhalix")
.Title("Khalix Symbols")
.Height(350)
.Width(465)
.Border(false)
.RootVisible(false)
.Root(Html.X().Node().NodeID("0"))
.DisplayField("text")
.Store(store =>
{
store.Add(Html.X().TreeStore()
.ID("treeKhalixEntities")
.AutoLoad(false)
// .Proxy(
// Html.X().AjaxProxy()
// .API(api =>
// {
// api.Read = Url.Action("GetChildren", "Khalix", new { area = "CARMA", instance = "App.cboInstance.getValue()", root = "App.cboRoot.getValue()" });
// })
// .Reader(reader => reader.Add(Html.X().JsonReader().Root("data")))
// )
);
}
)
//.Listeners(l => l.BeforeLoad.Fn = "nodeLoad")
My "GetTree" method is basically searching through my 8000 records and pulling back the appropriate ones recursively. They are being added to the tree via: khalixTree.GetRootNode().AppendChild(nodeCollectio n);
For my "GetChildren" method, I was trying to use an AjaxProxy reader and have also tried to use the BeforeLoad listener. Any advice as to what I need to do is much appreciated. If you need more code samples I am all for getting this one solved...
Thanks!