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,
Apologies for the delayed response.
Please note that for each level where you wish manual loading to occur, at least one record in the original datasource should exist which has that respective number of child levels.
For instance for 3 levels , there must be at least one row in the root table with a child which has a child.
Regarding accessing the columns in an a grid with autogenerated columns, I would suggest that you consider employing the InitializeRow event (or a stage in the page lifecycle where the grid rows are generated and accessible). At that point the autogenerated columns may be hidden using something similar to:
e.Row.Cells[0].Column.Hidden = true;
Please let me know if this helps.
OK an update on where I am. As with my last post I can not get it to load anything after the first child level, unless I do a new databind on the grid. The problem with this is that the user would have to re-expand everything. The other big issue I am having is the inability to hide collumns as if I set the AutoGenerateColumns to false nothing displays. This is a big issue as the people I am developing for absolutly do not want to see the IDs i need to link the tables. Below is the current version of my code.
Also can you post if you are looking into this or should I make a new post for these issues?
<igtbl:UltraWebGrid ID="gridProject" runat="server" DataKeyField="Projects" OnInitializeRow="gridProject_InitializeRow" DisplayLayout-ViewType="Hierarchical" Width="100%" Height="100%" OnInitializeLayout="gridProject_InitializeLayout" OnDemandLoad="gridProject_DemandLoad" EnableViewState="True"> <Bands> <igtbl:UltraGridBand BaseTableName="Territory" Expandable="Yes" DataKeyField="Projects" AllowUpdate="Yes" ChildBandColumn="PAProjID"> <Columns> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="TerritoryID" Key="TerritoryID" HeaderText="Column 0" Hidden="true" AllowUpdate="Yes"> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="TerritoryName" Key="TerritoryID" HeaderText="Territory" AllowUpdate="Yes"> </igtbl:UltraGridColumn> </Columns> <FilterOptions> <FilterDropDownStyle CustomRules="overflow:auto;" BackColor="White" BorderColor="Silver" BorderWidth="1px" BorderStyle="Solid" Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px" Width="200px"> <Padding Left="2px"></Padding> </FilterDropDownStyle> <FilterHighlightRowStyle BackColor="#151C55" ForeColor="#FFFFFF"> </FilterHighlightRowStyle> </FilterOptions> <AddNewRow Visible="Yes"> </AddNewRow> </igtbl:UltraGridBand> <igtbl:UltraGridBand BaseTableName="Job" Expandable="Yes" DataKeyField="PAProjID" IndentationType="Indented" AllowUpdate="Yes" ChildBandColumn="SMCID"> <Columns> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="PAProjID" Key="PAProjID" HeaderText="Job ID" AllowUpdate="Yes" Hidden="True"> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Job No" Key="Job No" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="JobDesc" Key="JobDesc" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="TerritoryID" Key="TerritoryID" AllowUpdate="Yes" Hidden="True"> <Header> <RowLayoutColumnInfo OriginX="3"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="3"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> </Columns> <AddNewRow Visible="Yes" View="Bottom"> </AddNewRow> </igtbl:UltraGridBand> <igtbl:UltraGridBand BaseTableName="SMContract" Expandable="Yes" ChildBandColumn="LocID" DataKeyField="SMCID" IndentationType="Indented" AllowUpdate="Yes"> <Columns> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="SMCID" Key="SMCID" AllowUpdate="Yes" Hidden="True"> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="SMCDesc" Key="SMCDesc" AllowUpdate="Yes"> <Header Caption="Contract Description"> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="PAProjID" Key="PAProjID" AllowUpdate="Yes" Hidden="True"> <Header> <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> </Columns> <AddNewRow Visible="Yes" View="Bottom"> </AddNewRow> </igtbl:UltraGridBand> <igtbl:UltraGridBand BaseTableName="Location" Expandable="Yes" ChildBandColumn="UnitID" DataKeyField="LocID" IndentationType="Indented" AllowUpdate="Yes"> <Columns> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="SMCID" Key="SMCID" AllowUpdate="Yes" Hidden="True"> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="LocID" Key="LocID" AllowUpdate="Yes" Hidden="True"> <Header> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Building" Key="Building" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Address" Key="Address" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="3"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="3"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="City" Key="City" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="4"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="4"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="State" Key="State" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="5"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="5"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Zip" Key="Zip" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="6"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="6"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> </Columns> <AddNewRow Visible="Yes" View="Bottom"> </AddNewRow> </igtbl:UltraGridBand> <igtbl:UltraGridBand BaseTableName="Units" Expandable="Yes" DataKeyField="UnitID" IndentationType="Indented" AllowUpdate="Yes"> <Columns> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="UnitID" Key="UnitID" AllowUpdate="Yes" Hidden="True"> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="LocID" Key="LocID" AllowUpdate="Yes" Hidden="True"> <Header> <RowLayoutColumnInfo OriginX="1" /> </Header> <Footer> <RowLayoutColumnInfo OriginX="1" /> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Unit" Key="Unit" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="2"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Type" Key="Type" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="3"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="3"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Manufacture" Key="Manufacture" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="4"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="4"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Controller" Key="Controller" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="5"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="5"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> <igtbl:UltraGridColumn Type="Custom" IsBound="True" BaseColumnName="Description" Key="Description" HeaderText="Maint Type" AllowUpdate="Yes"> <Header> <RowLayoutColumnInfo OriginX="6"></RowLayoutColumnInfo> </Header> <Footer> <RowLayoutColumnInfo OriginX="6"></RowLayoutColumnInfo> </Footer> </igtbl:UltraGridColumn> </Columns> <AddNewRow Visible="Yes" View="Bottom"> </AddNewRow> </igtbl:UltraGridBand> </Bands> <DisplayLayout AutoGenerateColumns="True" AllowSortingDefault="OnClient" HeaderClickActionDefault="SortMulti" ViewType="OutlookGroupBy" AddNewBox-Hidden="False" AllowColSizingDefault="Free" AllowColumnMovingDefault="OnServer" AllowDeleteDefault="Yes" AllowUpdateDefault="Yes" BorderCollapseDefault="Separate" RowHeightDefault="20px" RowSelectorsDefault="No" SelectTypeRowDefault="Extended" Version="4.00"> <FrameStyle Cursor="Default" Font-Size="8.25pt" Font-Names="Microsoft Sans Serif" ForeColor="White" BackColor="Window" Width="100%" Height="100%" VerticalAlign="Middle" Wrap="True" BorderColor="InactiveCaption" BorderStyle="Solid" BorderWidth="1px"> </FrameStyle> <RowAlternateStyleDefault BackColor="#FFE3C6"> </RowAlternateStyleDefault> <Pager> <Style BackColor="LightGray" BorderWidth="1px" BorderStyle="Solid"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px"></BorderDetails> </Style> </Pager> <EditCellStyleDefault BorderWidth="0px" BorderStyle="None"> </EditCellStyleDefault> <FooterStyleDefault BackColor="LightGray" BorderWidth="1px" BorderStyle="Solid"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px"> </BorderDetails> </FooterStyleDefault> <HeaderStyleDefault Font-Bold="True" Font-Size="8pt" Font-Names="Verdana" BorderColor="Black" BorderStyle="Solid" ForeColor="#000099" BackColor="LightGray" HorizontalAlign="Left"> <BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White" ColorRight="Black"></BorderDetails> </HeaderStyleDefault> <RowStyleDefault ForeColor="Black" BackColor="Window" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana"> <Padding Left="3px" /> <BorderDetails ColorLeft="Window" ColorTop="Window" /> </RowStyleDefault> <GroupByRowStyleDefault BackColor="Control" BorderColor="Window"> </GroupByRowStyleDefault> <SelectedRowStyleDefault ForeColor="White" BackColor="#0A75F0"> </SelectedRowStyleDefault> <GroupByBox> <Style BackColor="ActiveBorder" BorderColor="Window"></Style> </GroupByBox> <AddNewBox Hidden="False"> <Style BackColor="Window" BorderColor="InactiveCaption" BorderWidth="1px" BorderStyle="Solid"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px"></BorderDetails> </Style> </AddNewBox> <ActivationObject BorderStyle="Dotted"> </ActivationObject> <FilterOptionsDefault> <FilterDropDownStyle BackColor="White" BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" CustomRules="overflow:auto;" Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="8pt" Width="100%"> <Padding Left="2px" /> </FilterDropDownStyle> <FilterHighlightRowStyle BackColor="#151C55" ForeColor="#FFFFFF"> </FilterHighlightRowStyle> </FilterOptionsDefault> </DisplayLayout> </igtbl:UltraWebGrid>
public partial class JDBList : 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; 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); #endregion gridProject.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.Hierarchical; gridLoad(); } protected void gridLoad() { VisList<Territory> terrs = Lookups.getTerritories(Config.VisionManager, Config.CurrentUser.UserID, Config.CurrentEntity.Id); Search s = new Search(); foreach (Territory terr in terrs) { rowTerr = ds.Tables["Territory"].NewRow(); rowTerr["TerritoryID"] = terr.Id; rowTerr["TerritoryName"] = terr.Description; ds.Tables["Territory"].Rows.Add(rowTerr); //s = new Search(); //s.And(vMcpSearchView.Fields.Status, "A"); //s.And(vMcpSearchView.Fields.TerritoryId, terr.Id); //loadJob(s); } #region "Old loading code" //s = new Search(); //s.And(vMcpSearchView.Fields.Status, "A"); //s.And(vMcpSearchView.Fields.EntityId, 3); //s.And(vMcpSearchView.Fields.TerritoryId, 4); //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); // Search smcs = new Search(); // smcs.And(SmContract.Fields.PaProjectId, mcp.PaProjectId); // 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); // Search mcpls = new Search(); // mcpls.And(vMcpLocationsView.Fields.SmContractsId, smc.SmContractsId); // //mcpls.And(vMcpLocationsView.Fields.SmContractsId, 1710, CompareType.Not); // //mcpls.And(vMcpLocationsView.Fields.SmContractsId, 3522, CompareType.Not); // //mcpls.And(vMcpLocationsView.Fields.SmContractsId, 1909, CompareType.Not); // //mcpls.And(vMcpLocationsView.Fields.SmContractsId, 1910, CompareType.Not); // 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); // Search frms = new Search(); // frms.And(vFrmElevMainView.Fields.LocationsId, mcpl.LocationsId); // 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); // } // } // } // } //} #endregion gridProject.DataSource = ds; gridProject.DataMember = ds.Tables["Territory"].TableName; gridProject.DataBind(); } protected void gridProject_DemandLoad(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { string bandTN = e.Row.Band.BaseTableName; if (bandTN == "Territory") { 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); loadJob(s); // Create child rows foreach (DataRow dataRow in ds.Tables["Job"].Rows) { UltraGridRow row = new UltraGridRow(true); row.ShowExpand = true; row.Expanded = true; row.Expand(true); e.Row.Rows.Add(row); foreach (UltraGridCell cell in row.Cells) { cell.Value = dataRow[cell.Key]; } } } else if (bandTN == "Job") { 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); loadContract(smcs); // Create child rows foreach (DataRow dataRow in ds.Tables["SMContract"].Rows) { UltraGridRow row = new UltraGridRow(true); row.ShowExpand = true; row.Expanded = false; row.Expand(true); e.Row.Rows.Add(row); foreach (UltraGridCell cell in row.Cells) { cell.Value = dataRow[cell.Key]; } } } else if (bandTN == "SMContract") { int smcID = (int)e.Row.Cells.FromKey("SMCID").Value; Search mcpls = new Search(); mcpls.And(vMcpLocationsView.Fields.SmContractsId, smcID); loadLocation(mcpls); // Create child rows foreach (DataRow dataRow in ds.Tables["Location"].Rows) { UltraGridRow row = new UltraGridRow(true); row.ShowExpand = true; row.Expanded = false; row.Expand(true); e.Row.Rows.Add(row); foreach (UltraGridCell cell in row.Cells) { cell.Value = dataRow[cell.Key]; } } } else if (bandTN == "Location") { 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); loadUnit(frms); // 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]; } } } gridProject.DataBind(); //gridProject.ExpandAll(); //e.Row.ExpandAncestors(); e.Row.Expand(true); } protected void gridProject_InitializeRow(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e) { DataRow row = ((DataRowView)e.Data).Row; string band = e.Row.Band.BaseTableName; if (band != "Units") { e.Row.ShowExpand = true; e.Row.Expanded = false; } } protected void gridProject_InitializeLayout(object sender, LayoutEventArgs e) { // Enable LoadOnDemand e.Layout.LoadOnDemand = LoadOnDemand.Manual; } protected void loadJob(Search s) { 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); } } protected void loadContract(Search s) { foreach (SmContract smc in visMan.GetList<SmContract>(s)) { rowSMC = ds.Tables["SMContract"].NewRow(); rowSMC["SMCID"] = smc.SmContractsId; rowSMC["SMCDesc"] = smc.ProjDesc; rowSMC["PAProjID"] = smc.PaProjectId; ds.Tables["SMContract"].Rows.Add(rowSMC); } } protected void loadLocation(Search s) { foreach (vMcpLocationsView mcpl in visMan.GetList<vMcpLocationsView>(s)) { 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); } } protected void loadUnit(Search s) { foreach (vFrmElevMainView unit in visMan.GetList<vFrmElevMainView>(s)) { 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); } } } }
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);
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; }
Thank you for replying. Some questions with that example you provided. Would I declare the tables like I have already and then fill just the territory table, waiting to fill the sub tables till they are expanded?
Thank you for the help!
As a side note I am looking in to possibly upgrading to 11.1 sicne that would allow us to move to the webgrid slowly. Just need to figure how much work would need to be done to allow 11.1 to work coming from 6.2.