I've been combing documentation, the API's and this forum, but I am coming up a little short for my situation.
I have a DataSet with 3 DataTables.
ParentDataTable
ChildOneDataTable
ChildTwoDataTable
Each ChildDataTable is tied back to the ParentDataTable with a relation.
I would like to specify to show the the data in a heirarchical view between the ParentDataTable and ChildTwoDataTable.
I am setting the WebGrid.DataSource property in the code behind and then calling the DataBind Method.
How do I specify to show two bands and bind to the appropriate datatables in the dataset?
The version I'm using is NetAdvantage 3.5.
Is ChildTwoDataTable directly related to ParentDataTable, or is the relationship indirect, with ChildTwoDataTable directly related to ChildOneDataTable which in turn is directly related to ParentDataTable?
If the relationship is direct, or if you are willing to show the intermediate table, you can do something like this:
http://forums.infragistics.com/forums/p/3298/17902.aspx#17902
If the relationship is indirect, and you need to not show the middle table, I would sugest that you combine the two ChildTables into one denormalized table in your datasource.
Both ChildOneDataTable and ChildTwoDataTable are directly related to the ParentDataTable.
Ideally, I would like to instruct the Grid to create a band for ParentDataTable and ChildTwoDataTable before the DataBind (There may be times in the future where I would like to Bind to ParentDataTable and ChildOneDataTable and not display ChildTwoDataTable).
In a perfect world, I would expect this to work:
(C#)
revenueCalculationsUltraWebGrid.Bands.Clear();
Infragistics.WebUI.UltraWebGrid.UltraGridBand yearUltraGridBand =
new Infragistics.WebUI.UltraWebGrid.UltraGridBand(true);
yearUltraGridBand.BaseTableName = "ParentDataTable";
revenueCalculationsUltraWebGrid.Bands.Add(yearUltraGridBand);
Infragistics.WebUI.UltraWebGrid.UltraGridBand detailsUltraGridBand =
detailsUltraGridBand.BaseTableName = "ChildTwoDataTable"; revenueCalculationsUltraWebGrid.Bands.Add(detailsUltraGridBand);
elamberton said:revenueCalculationsUltraWebGrid.Bands.Clear(); Infragistics.WebUI.UltraWebGrid.UltraGridBand yearUltraGridBand = new Infragistics.WebUI.UltraWebGrid.UltraGridBand(true); yearUltraGridBand.BaseTableName = "ParentDataTable"; revenueCalculationsUltraWebGrid.Bands.Add(yearUltraGridBand); Infragistics.WebUI.UltraWebGrid.UltraGridBand detailsUltraGridBand = new Infragistics.WebUI.UltraWebGrid.UltraGridBand(true); detailsUltraGridBand.BaseTableName = "ChildTwoDataTable"; revenueCalculationsUltraWebGrid.Bands.Add(detailsUltraGridBand);
I am using this code to bind the grid, but its showing me only two levels why is that. please help . If i need to add more bands, how do i do that. In designer bands doesnt seem to be a colleciton. can u give me step by step to add bands if that is the missing part.
UI ->
<igtbl:UltraWebGrid ID="UG1" runat="server" Browser="Xml" Height="100%" Width="100%" OnDataBinding="UG1_DataBinding"> <DisplayLayout AllowAddNewDefault="Yes" RowHeightDefault="18px" Version="3.00" SelectTypeRowDefault="Single" ViewType="OutlookGroupBy" SelectTypeCellDefault="Extended" BorderCollapseDefault="Separate" AllowColSizingDefault="Free" Name="ctl00xUG1" TableLayout="Fixed" SelectTypeColDefault="Extended" AllowUpdateDefault="Yes"> <AddNewBox Hidden="False" ButtonConnectorStyle="Solid" ButtonConnectorColor="Silver" View="Compact"> <ButtonStyle Cursor="Hand" BorderWidth="1px" BorderColor="White" BorderStyle="Outset" BackColor="Gray"> </ButtonStyle> <BoxStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px"> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </BoxStyle> </AddNewBox> <Pager PageSize="20" Alignment="Center" AllowPaging="True"> <PagerStyle BackColor="LightGray" BorderStyle="Solid" BorderWidth="1px" ForeColor="Black"> <Padding Left="0px" Top="2px" /> <BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px" /> </PagerStyle> </Pager> <HeaderStyleDefault BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana" BorderStyle="Solid" HorizontalAlign="Left" ForeColor="Black" BackColor="#CBD6A6"> <Padding Left="5px" Right="5px"></Padding> <BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails> </HeaderStyleDefault> <GroupByRowStyleDefault BorderWidth="1px" BorderColor="White" BorderStyle="Outset" BackColor="DarkGray"> </GroupByRowStyleDefault> <RowSelectorStyleDefault BorderWidth="1px" BorderStyle="None" BackColor="White"> </RowSelectorStyleDefault> <FrameStyle Width="100%" Cursor="Hand" BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana" BorderStyle="Solid" BackColor="#FAFCF1" Height="100%"> </FrameStyle> <FooterStyleDefault BorderWidth="1px" BorderStyle="Solid" BackColor="LightGray"> <BorderDetails ColorTop="White" WidthLeft="1px" WidthTop="1px" ColorLeft="White"></BorderDetails> </FooterStyleDefault> <ActivationObject BorderColor="170, 184, 131" BorderWidth=""> </ActivationObject> <GroupByBox ButtonConnectorStyle="Solid" ButtonConnectorColor="Silver"> <BandLabelStyle Cursor="Default" BorderWidth="1px" BorderColor="White" BorderStyle="Outset" BackColor="Gray"> </BandLabelStyle> <BoxStyle BackColor="DarkGray" BorderColor="White" BorderStyle="Outset" BorderWidth="1px"> </BoxStyle> </GroupByBox> <RowExpAreaStyleDefault BackColor="WhiteSmoke"> </RowExpAreaStyleDefault> <EditCellStyleDefault VerticalAlign="Middle" BorderWidth="0px" Font-Size="8pt" Font-Names="Verdana" BorderStyle="None" HorizontalAlign="Left"> </EditCellStyleDefault> <SelectedRowStyleDefault ForeColor="White" BackColor="#BECA98"> </SelectedRowStyleDefault> <SelectedGroupByRowStyleDefault BorderWidth="1px" BorderColor="White" BorderStyle="Outset" ForeColor="White" BackColor="#CF5F5B"> </SelectedGroupByRowStyleDefault> <RowAlternateStyleDefault BackColor="#E0E0E0"> </RowAlternateStyleDefault> <RowStyleDefault VerticalAlign="Middle" BorderWidth="1px" Font-Size="8pt" Font-Names="verdana" BorderColor="#AAB883" BorderStyle="Solid" HorizontalAlign="Left" ForeColor="#333333" BackColor="White"> <Padding Left="7px" Right="7px"></Padding> <BorderDetails WidthLeft="0px" WidthTop="0px"></BorderDetails> </RowStyleDefault> <Images> <CollapseImage Url="../Images/ig_treeXPMinus.GIF" /> <ExpandImage Url="../Images/ig_treeXPPlus.GIF" /> <CurrentRowImage Url="../Images/arrow_brown2_beveled.gif" /> <CurrentEditRowImage Url="../Images/arrow_brown2_beveled.gif" /> </Images> </DisplayLayout> <Bands> <igtbl:UltraGridBand> <AddNewRow View="NotSet" Visible="NotSet"> </AddNewRow> </igtbl:UltraGridBand> </Bands> </igtbl:UltraWebGrid>
UI.cs->
Data layer -->
System.Data.DataSet contactsDataSet1 = new System.Data.DataSet();
SqlDataAdapter cmdCustomers = new SqlDataAdapter("select * from customer", dbConnection); SqlDataAdapter cmdOrders = new SqlDataAdapter("select * from location", dbConnection); SqlDataAdapter cmdSystems = new SqlDataAdapter("select * from systems", dbConnection); cmdCustomers.Fill(contactsDataSet1, "Customer"); cmdOrders.Fill(contactsDataSet1, "Location"); cmdSystems.Fill(contactsDataSet1, "Systems"); contactsDataSet1.Relations.Add("Customers", contactsDataSet1.Tables["Customer"].Columns["CustomerId"], contactsDataSet1.Tables["Location"].Columns["CustomerId"]);
contactsDataSet1.Relations.Add("Locations", contactsDataSet1.Tables["Location"].Columns["LocationId"], contactsDataSet1.Tables["Systems"].Columns["LocationId"]);
return contactsDataSet1;