Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
More then 2 Level TreeView
posted

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

-Folder 1

--Folder 1 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, falsefalsefalseout 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)), falsefalsefalseout 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)), falsefalsefalseout 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
Parents
  • 135
    posted

    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?

Reply Children