Hi,
I've implemented an igGrid with relative igHierarchicalGrid. I set updating feature on the first grid and the same on the second one (child grid).It works correctly for both grids, but the problem is the following one: if I have a row without children I am not able to create new ones, because I can't see '+' expand character and I am not able to open the child grid...How can I have a child grid also for those rows that do not have children?
Thanks
Flavio
Hello Flavio,
Thank you for posting in our forums.
I think that a similar question of yours was answered some time ago by Angel Todorov
http://ko.infragistics.com/community/forums/p/66844/337969.aspx#337969
You need to enable Load on demand (LoadOnDemand = true in the MVC wrapper, or set initialDataBindDepth to 0 in the options, if you are using just the client-side widget).
Hope this helps.
Yes,
sorry: I forgot to specify that I asked this thing time ago. To be honest this newer question is the same, but when I asked it the first time I was using Infragistics 11.2...now I am using 12.2 and I hoped something changed.Do you confirm me that Angel suggestion and yours is the only one possible solution?I mean: I don't want to use LoadOnDemand, but at the same time I completely define the GridModel by controller side, and I don't understand why I can't define by controller side the initialDataBindDepth property...Flavio
Sorry for the pressing, but I need to solve it.
Any ideas?
That's ok.I started working on igHierarchicalGrid with Load on Demand.I followed up this sample:
http://ko.infragistics.com/products/jquery/sample/hierarchical-grid/hierarchical-grid-load-on-demand
and this little manual:
http://help.infragistics.com/Help/NetAdvantage/jQuery/2012.2/CLR4.0/html/igHierarchicalGrid_Load_on_Demand.html#loadOnDemandMVC
I am in the case of MVC controller side hierarchical grid (C# syntax).I think I completely did all the things I found in the sample and in the manual page...so, my code is the following one: public ActionResult Index() { GridModel gm = new GridModel(); _createGridModel(gm); return View(gm); } public JsonResult BindParent() { GridModel gm = new GridModel(); _createGridModel(gm); ...loading parentObjectList as List<ParentObject>() gm.DataSource = parentObjectList .AsQueryable(); return gm.GetData(); } public JsonResult BindChild(string path, string layout) { GridModel gm = new GridModel(); _createGridModel(gm); ...loading childrenObjectList as List<ChildrenObject>() gm.DataSource = childrenObjectList .AsQueryable(); return gm.GetData(path, layout); } private GridModel _createGridModel(GridModel gm) { ...loading parentObjectList as List<ParentObject>() gm.ID = "parent_grid"; gm.DataSource = parentObjectList .AsQueryable(); gm.AutoGenerateColumns = false; gm.AutoGenerateLayouts = false; gm.PrimaryKey = "Id"; gm.Width = "100%"; #region Grid Columns gm.Columns.Add(new GridColumn("Id", "Id", "number", "0")); gm.Columns.Add(new GridColumn("Description", "Description", "string", "35%")); ... gm.RenderCheckboxes = true; #endregion #region Grid Hiding GridHiding hiding = new GridHiding(); ColumnHidingSetting hSetId = new ColumnHidingSetting(); hSetId.ColumnKey = "Id"; hSetId.AllowHiding = false; hSetId.Hidden = true; hiding.ColumnSettings.Add(hSetId); ColumnHidingSetting hSetDescription = new ColumnHidingSetting(); hSetDescription .ColumnKey = "Description"; hSetDescription .AllowHiding = false; hSetDescription .Hidden = false; hiding.ColumnSettings.Add(hSetDescription ); ... gm.Features.Add(hiding); #endregion
#region HierarchicalGrid GridColumnLayoutModel hgml = _getHierarchicalGridColumnLayout(); gm.ColumnLayouts.Add(hgml); #endregion gm.LoadOnDemand = true; gm.DataSourceUrl = Url.Action("BindParent"); gm.ColumnLayouts[0].DataSourceUrl = Url.Action("BindChild"); return gm; } private GridColumnLayoutModel _getHierarchicalGridColumnLayout() { GridColumnLayoutModel hierarchicalGm = new GridColumnLayoutModel(); hierarchicalGm.ID = "hgrid"; hierarchicalGm.AutoGenerateColumns = true; hierarchicalGm.AutoGenerateLayouts = false; hierarchicalGm.Key = "Allegati"; hierarchicalGm.PrimaryKey = "Id"; hierarchicalGm.ForeignKey = "DispositivoId"; hierarchicalGm.Caption = "Allegati"; hierarchicalGm.Width = "100%"; return hierarchicalGm; }But I still get this error:
Error: The remote request to fetch data has failed: (error) undefined @ ...Scripts/IG/modules/infragistics.ui.grid.framework.js:25
I also tried to set data binding on js code:
$(function () { $("#grid_anagrafica_tipologie_dispositivo").live("iggriddatabinding", function (evt, ui) { $("#grid_anagrafica_tipologie_dispositivo").igGrid("option", "dataSourceType", "json"); }); });
But the result is the same...Note that parent grid has been creating right: I can see all the objects with a '+' on the left. The problem is when I try to expand a parent record into its children: I can see the subgrid rendering with all the columns, but the application stops with the loading picture thread, and I can see on the debugging console the error mentioned above...Through the debug I can see that BindChild method is correctly reached, and the error is given here, at the end of the code: gm.GetData(path, layout);returns a null object exception... I don't know if I forgot some properties to be set, or if I did something wrong in the datasource/databinding management...Thanks in advance!!!!Flavio
At this momentI am not aware of another approach which can solve your issue out of the box.