Hi,
im new to Infragistics Components and now im trying to use the TreeView with Remote Loading. I followed the example http://www.igniteui.com/tree/aspnet-mvc-load-on-demand
Unfortunately, the Methods which are used there to populate the data for the tree are not documentated RepositoryFactory.GetCategoryRepository(IncludeChildren.Products).Get();
RepositoryFactory.GetCategoryRepository().Get();
While im trying to achieve this, I get a bit confused if this use is correct and how to get a 2 level.
I'm trying to build a tree like this:
Documentation 1
-Folder 1
--Folder 1 2
-Folder 2
--Folder 2 2
Documentation 2
I build a MVC Controler with the following methods:
public ActionResult InfragisticsTree() { var blManual = new SilverlightApplication.Web.BusinessLogic.Manual(); var blCategories = new SilverlightApplication.Web.BusinessLogic.Category(); var dbStat = new SilverlightApplication.Web.DataContainer.DatabaseActionStatus(); var test = blManual.GetAllManuals(OBCUtilities.ModuleType.Document, false).Select(x => new InfragisticsTreeViewModel { ID = x.ManualID, Name = x.Name, Type = "C", Items = blCategories.GetCategoriesForManual(x.ManualID, false, false, false, out dbStat).Select(c => new InfragisticsTreeViewModel { ID = c.CategoryID, Name = c.Name, Type = "C", }), ItemsCount = 1 }); return View(test); }
[ActionName("tree-data-on-demand")] public JsonResult TreeDataOnDemand(string path, string binding, int depth) { var model = new Infragistics.Web.Mvc.TreeModel(); var blCategories = new SilverlightApplication.Web.BusinessLogic.Category(); var dbStat = new SilverlightApplication.Web.DataContainer.DatabaseActionStatus(); var catList = new SilverlightApplication.Web.DataContainer.CategoryList(); switch (depth) { case 0: model.DataSource = blCategories.GetCategoriesForManual(Guid.Parse(path.Split(':')[1].Substring(0,36)), false, false, false, out dbStat) .Select(x => new InfragisticsTreeViewModel { ID = x.ManualID, Name = x.Name, Type = "C" }); break; default: model.DataSource = blCategories.GetAllCategoriesForCategory(Guid.Parse(path.Split(':')[1].Substring(0, 36)), false, false, false, out dbStat) .Select(x => new InfragisticsTreeViewModel { ID = x.ManualID, Name = x.Name, Type = "C" }); break; } return model.GetData(path, binding); }My cshtml is same as in the example.Some questions:Why do I have to Inlcude the children in the Tree Model when I'm just showing the First Level. A HasChildren property would be enough for showing the expand Arrow on the treeitem?Why I get a model.GetData Error that its null? How is this expected to work? What should the TreeDataOnDemand return actually?Kind Regards,Tim
Ok, so far I found out that the TreeDataOnDemand just has to be a JsonResult of the InfragisticsTreeViewModel result.
How do I prevent the loading of the Items (Products in example) but show the expand arrow on a Tree Item?
Hi Tim,
Thanks for posting in our forums!
You can find more information on how to setup load on demand in our documentation here:
http://www.igniteui.com/help/igtree-optimize-performance#configure-load-on-demand-for-mvc
The TreeModel.GetData method will query the current datasource for the information needed to load the children. This means the TreeModel needs to look ahead to find any children. If a collection is found that matches the ChildDataProperty, then the item will render expansion arrows, otherwise this item is considered a leaf node. This collection does not need to be filled out, just instantiated.
The path argument that is passed to the TreeDataOnDemand method contains the local path, so you will need to know which tier of data to supply as the TreeModel.DataSource. That is where the depth argument comes in. You can use this to let the TreeModel know what tier of data to query.
I have attached a simple sample using your example. I have slightly modified it some to help emphasize the hierarchy detection of the igTree.
If you have any further questions or concerns with this, please let me know and I will be glad to help.
Thanks for the answer.
Is there a MVC only help? Quite hard to find the correct help pages ;-)
There isn't an exclusive help for MVC, but there is a subsection and our help pages can be easily searched to filter MVC articles.
http://www.igniteui.com/help/asp.net-mvc-landingpage
http://www.igniteui.com/help/search?query=MVC
If you need anything else, please let me know.