I am trying to get a grid to load on demand when a row is expanded. When I tried to follow the sample on the page http://ko.infragistics.com/products/aspnet/sample/hierarchical-data-grid/manual-load-on-demand I found out that I do not have the ContainerRowCancelEventArgs object (probably since my version does not have the namespace Infragistics.Web.UI.GridControls. Is there any way for me to acheive the load on demand in my version? Thank you.
Instead of repasting my code, you can se it at the post below:
http://ko.infragistics.com/community/forums/p/71566/361885.aspx
My version is:
Version=6.2.20062.1059
Hello aseidel,
Thank you for posting in the community.
Please note that the UltraWebGrid controls is outdated and has been retired as of version 11.2. The samples you have mentioned refer to the new WebHierarchicalDataGrid:
http://help.infragistics.com/NetAdvantage/ASPNET/2012.1/CLR4.0/?page=WebHierarchicalDataGrid_Getting_Started_with_WebHierarchicalDataGrid.html
I would strongly suggest that you consider upgrading your version and switching to the AIKIDO toolset.
An article demonstrating how Manual LOD may be configured for the UltraWebGrid is avaialble at:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.1/CLR4.0/html/Infragistics4.WebUI.UltraWebGrid.v11.1~Infragistics.WebUI.UltraWebGrid.UltraWebGrid~DemandLoad_EV.html
Please feel free to contact me if you have any questions.
Ok I beleive I have my code set up like in the sample you provided (thank you), but even though I have the e.Row.ShowExpand = true; set it still is not showing the expand button, which means I dont know if it will actually load the data or not. Any suggestions? I will past my current c# code below (it is long).
Thank you,
public partial class TEST_TESTRevenueRecognition : BasePage { DataSet ds = new DataSet("Projects"); DataColumn[] keys = new DataColumn[1]; DataColumn[] keys2 = new DataColumn[2]; DataRow rowTerr; DataRow rowPAProj; DataRow rowSMC; DataRow rowLoc; DataRow rowUnit; ArrayList unitID = new ArrayList(); protected void Page_Load(object sender, EventArgs e) { #region "Table Definition" ds.Tables.Add(new DataTable("Territory")); ds.Tables["Territory"].Columns.Add(new DataColumn("TerritoryID", typeof(int))); ds.Tables["Territory"].Columns.Add(new DataColumn("TerritoryName", typeof(string))); keys[0] = ds.Tables["Territory"].Columns["TerritoryID"]; ds.Tables["Territory"].PrimaryKey = keys; //vMcpSearchView ds.Tables.Add(new DataTable("Job")); ds.Tables["Job"].Columns.Add(new DataColumn("PAProjID", typeof(int))); ds.Tables["Job"].Columns.Add(new DataColumn("Job No", typeof(string))); ds.Tables["Job"].Columns.Add(new DataColumn("JobDesc", typeof(string))); ds.Tables["Job"].Columns.Add(new DataColumn("TerritoryID", typeof(int))); keys[0] = ds.Tables["Job"].Columns["PAProjID"]; ds.Tables["Job"].PrimaryKey = keys; //SmContract ds.Tables.Add(new DataTable("SMContract")); ds.Tables["SMContract"].Columns.Add(new DataColumn("SMCID", typeof(int))); ds.Tables["SMContract"].Columns.Add(new DataColumn("SMCDesc", typeof(string))); ds.Tables["SMContract"].Columns.Add(new DataColumn("PAProjID", typeof(int))); keys[0] = ds.Tables["SMContract"].Columns["SMCID"]; ds.Tables["SMContract"].PrimaryKey = keys; //vMcpLocationsView ds.Tables.Add(new DataTable("Location")); ds.Tables["Location"].Columns.Add(new DataColumn("SMCID", typeof(int))); ds.Tables["Location"].Columns.Add(new DataColumn("LocID", typeof(int))); ds.Tables["Location"].Columns.Add(new DataColumn("Building", typeof(string))); ds.Tables["Location"].Columns.Add(new DataColumn("Address", typeof(string))); ds.Tables["Location"].Columns.Add(new DataColumn("City", typeof(string))); ds.Tables["Location"].Columns.Add(new DataColumn("State", typeof(string))); ds.Tables["Location"].Columns.Add(new DataColumn("Zip", typeof(string))); keys2[0] = ds.Tables["Location"].Columns["SMCID"]; keys2[1] = ds.Tables["Location"].Columns["LocID"]; ds.Tables["Location"].PrimaryKey = keys2; //vFrmElevMainView ds.Tables.Add(new DataTable("Units")); ds.Tables["Units"].Columns.Add(new DataColumn("SMCID", typeof(int))); ds.Tables["Units"].Columns.Add(new DataColumn("UnitID", typeof(int))); ds.Tables["Units"].Columns.Add(new DataColumn("LocID", typeof(int))); ds.Tables["Units"].Columns.Add(new DataColumn("Unit", typeof(string))); ds.Tables["Units"].Columns.Add(new DataColumn("Type", typeof(string))); ds.Tables["Units"].Columns.Add(new DataColumn("Manufacture", typeof(string))); ds.Tables["Units"].Columns.Add(new DataColumn("Controller", typeof(string))); ds.Tables["Units"].Columns.Add(new DataColumn("Description", typeof(string))); keys2[0] = ds.Tables["Units"].Columns["SMCID"]; keys2[1] = ds.Tables["Units"].Columns["UnitID"]; ds.Tables["Units"].PrimaryKey = keys2; #endregion gridLoad(); } protected void gridLoad() { Search s = new Search(); s.And(Territory.Fields.EntityId, 3); foreach (Territory terr in visMan.GetList<Territory>(s)) { rowTerr = ds.Tables["Territory"].NewRow(); rowTerr["TerritoryID"] = terr.Id; rowTerr["TerritoryName"] = terr.Description; ds.Tables["Territory"].Rows.Add(rowTerr); } DataColumn[] locDC = { ds.Tables["Location"].Columns["LocID"], ds.Tables["Location"].Columns["SMCID"] }; DataColumn[] unitDC = { ds.Tables["Units"].Columns["LocID"], ds.Tables["Units"].Columns["SMCID"] }; ds.Relations.Add(ds.Tables["Territory"].Columns["TerritoryID"], ds.Tables["Job"].Columns["TerritoryID"]); ds.Relations.Add(ds.Tables["Job"].Columns["PAProjID"], ds.Tables["SMContract"].Columns["PAProjID"]); ds.Relations.Add(ds.Tables["SMContract"].Columns["SMCID"], ds.Tables["Location"].Columns["SMCID"]); ds.Relations.Add(locDC, unitDC); gridProject.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.Hierarchical; gridProject.DataSource = ds; //gridProject.DataMember = ds.Tables["Territory"].TableName; gridProject.DataBind(); } protected void UltraWebGrid1_DemandLoad(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { int band = e.Row.BandIndex; if (band == 0) { int terr = (int)e.Row.Cells.FromKey("TerritoryID").Value; Search s = new Search(); s.And(vMcpSearchView.Fields.Status, "A"); s.And(vMcpSearchView.Fields.TerritoryId, terr); foreach (vMcpSearchView mcp in visMan.GetList<vMcpSearchView>(s)) { rowPAProj = ds.Tables["Job"].NewRow(); rowPAProj["PAProjID"] = mcp.PaProjectId; rowPAProj["Job No"] = mcp.Projectno; rowPAProj["JobDesc"] = mcp.Descr; rowPAProj["TerritoryID"] = mcp.TerritoryId; ds.Tables["Job"].Rows.Add(rowPAProj); } // Create child rows foreach (DataRow dataRow in ds.Tables["Job"].Rows) { UltraGridRow row = new UltraGridRow(true); e.Row.Rows.Add(row); foreach (UltraGridCell cell in row.Cells) { cell.Value = dataRow[cell.Key]; } } } else if (band == 1) { int papID = (int)e.Row.Cells.FromKey("PAProjID").Value; Search smcs = new Search(); smcs.And(SmContract.Fields.PaProjectId, papID); smcs.And(SmContract.Fields.Active, 1); foreach (SmContract smc in visMan.GetList<SmContract>(smcs)) { rowSMC = ds.Tables["SMContract"].NewRow(); rowSMC["SMCID"] = smc.SmContractsId; rowSMC["SMCDesc"] = smc.ProjDesc; rowSMC["PAProjID"] = smc.PaProjectId; ds.Tables["SMContract"].Rows.Add(rowSMC); } // Create child rows foreach (DataRow dataRow in ds.Tables["SMContract"].Rows) { UltraGridRow row = new UltraGridRow(true); e.Row.Rows.Add(row); foreach (UltraGridCell cell in row.Cells) { cell.Value = dataRow[cell.Key]; } } } else if (band == 2) { int smcID = (int)e.Row.Cells.FromKey("SMCID").Value; Search mcpls = new Search(); mcpls.And(vMcpLocationsView.Fields.SmContractsId, smcID); foreach (vMcpLocationsView mcpl in visMan.GetList<vMcpLocationsView>(mcpls)) { rowLoc = ds.Tables["Location"].NewRow(); rowLoc["SMCID"] = mcpl.SmContractsId; rowLoc["LocID"] = mcpl.LocationsId; rowLoc["Building"] = mcpl.BldgName; rowLoc["Address"] = mcpl.Address; rowLoc["City"] = mcpl.City; rowLoc["State"] = mcpl.State; rowLoc["Zip"] = mcpl.Zip; ds.Tables["Location"].Rows.Add(rowLoc); } // Create child rows foreach (DataRow dataRow in ds.Tables["Location"].Rows) { UltraGridRow row = new UltraGridRow(true); e.Row.Rows.Add(row); foreach (UltraGridCell cell in row.Cells) { cell.Value = dataRow[cell.Key]; } } } else if (band == 3) { int locID = (int)e.Row.Cells.FromKey("LocID").Value; Search frms = new Search(); frms.And(vFrmElevMainView.Fields.LocationsId, locID); frms.And(vFrmElevMainView.Fields.SmContractsId, null, CompareType.Not); foreach (vFrmElevMainView unit in visMan.GetList<vFrmElevMainView>(frms)) { string uniqArray = unit.ElevatorsId.ToString() + unit.SmContractsId.ToString(); if (!unitID.Contains(uniqArray)) { rowUnit = ds.Tables["Units"].NewRow(); rowUnit["SMCID"] = unit.SmContractsId; rowUnit["UnitID"] = unit.ElevatorsId; rowUnit["LocID"] = unit.LocationsId; rowUnit["Unit"] = unit.Unit; rowUnit["Type"] = unit.ElevTypeDesc; rowUnit["Manufacture"] = unit.ElevManuDesc; rowUnit["Controller"] = unit.ElevCtrlName; rowUnit["Description"] = unit.Description; ds.Tables["Units"].Rows.Add(rowUnit); unitID.Add(uniqArray); } } // Create child rows foreach (DataRow dataRow in ds.Tables["Units"].Rows) { UltraGridRow row = new UltraGridRow(true); e.Row.Rows.Add(row); foreach (UltraGridCell cell in row.Cells) { cell.Value = dataRow[cell.Key]; } } } } protected void gridProject_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { DataRow row = ((DataRowView)e.Data).Row; int band = e.Row.BandIndex; if (band != 4) e.Row.ShowExpand = true; } protected void gridProject_InitializeLayout(object sender, LayoutEventArgs e) { // Enable LoadOnDemand e.Layout.LoadOnDemand = LoadOnDemand.Manual; }
Ok, I figured that issue out, I forgot to add the calls in the aspx file. The new issue that I cant figure out though is this, when it loads the next level it adds the expand button, but it displays it as a collapse button and it colapses th expanded data. This means I only get to the first child level and am not able to get to any of the other children levels. I even tried adding the code below for each location I am adding rows.
Thank you
UltraGridRow row = new UltraGridRow(true); row.ShowExpand = true; row.Expanded = false; row.Expand(true); e.Row.Rows.Add(row);