Hi All,
I had a parent and and two child bands in WHDG. where as i need to bind the sum of Child Column value to Parent Column at the time of DataBinding. i atteched an jpg file..plz give me reply..
am using 2009.2 version
Regards
Naag
Hi Naag,
Just following up to check if whether your issue is resolved. Please contact me if you need further assistance.
Best Regards,
Petar IvanovDeveloper Support EngineerInfragistics, Inc.http://ko.infragistics.com/support
I have created a sample which I believe addresses your requirements. The summing, however has to be done in the DataSet itself before data binding and the sample illustrates how you can add such columns to your set.
For clarity, here is the code used for populating the DataSet:
private DataSet populateDataSet() { DataSet ds = new DataSet(); DataTable Parent = new DataTable(); Parent.TableName = "Parent"; DataTable Child = new DataTable(); Child.TableName = "Child"; Parent.Columns.Add("ID"); Parent.Columns.Add("Name"); DataColumn[] col = new DataColumn[1]; col[0] = Parent.Columns["ID"]; Parent.PrimaryKey = col; DataRow row = Parent.NewRow(); row.SetField<int>("ID", 0); row.SetField<string>("Name", "Alice"); Parent.Rows.Add(row); row = Parent.NewRow(); row.SetField<int>("ID", 1); row.SetField<String>("Name", "Bob"); Parent.Rows.Add(row); Child.Columns.Add("ID"); Child.Columns.Add("Address"); Child.Columns.Add("Count", typeof(int)); row = Child.NewRow(); row.SetField<int>("ID", 0); row.SetField<string>("Address", "Paris"); row.SetField<int>("Count", 5); Child.Rows.Add(row); row = Child.NewRow(); row.SetField<int>("ID", 1); row.SetField<string>("Address", "Rome"); row.SetField<int>("Count", 9); Child.Rows.Add(row); row = Child.NewRow(); row.SetField<int>("ID", 1); row.SetField<string>("Address", "London"); row.SetField<int>("Count", 2); Child.Rows.Add(row); row = Child.NewRow(); row.SetField<int>("ID", 0); row.SetField<string>("Address", "LosAngeles"); row.SetField<int>("Count", 9); Child.Rows.Add(row); ds.Tables.Add(Parent); ds.Tables.Add(Child); DataRelation relation = new DataRelation("IDRelation", Parent.Columns["ID"], Child.Columns["ID"]); ds.Relations.Add(relation); // Add the column in the parent DataTable which Sums the values from the children based on the id relation Parent.Columns.Add("Sum", typeof(int), "Sum(Child(IDRelation).Count)"); return ds; }
Additionally, you may want to consider to employ the Summary row feature of the grid. You can find information about that behavior in our documentation at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.1/CLR4.0/?page=WebHierarchicalDataGrid_Summary_Row.html
Please tell me if this helps.
Hi Petar,
Thanks for your reply... here how i am using my dataset for hierarchical display
.Aspx
<ig:WebHierarchicalDataGrid ID="WebHierarchicalDataGrid1" runat="server" Height="712px"
Width="827px" DataKeyFields="ID" DataMember="Parent" AutoGenerateBands="False" OnInitializeRow="WebHierarchicalDataGrid1_OnInitializeRow"
AutoGenerateColumns="False" Key="Parent">
<Columns>
<ig:BoundDataField DataFieldName="FrameWorkName" Key="FrameWorkName" >
<Header Text="Authratitive Source" />
<Header Text="Authratitive Source"></Header>
</ig:BoundDataField>
<ig:TemplateDataField Key="OpenFindings">
<Header Text="OpenFindings" />
<ItemTemplate>
<asp:Label ID="Label_ParentOpenFindings" runat="server" Text='<%# Eval("OpenFindings") %>' Width="250px"></asp:Label>
</ItemTemplate>
</ig:TemplateDataField>
<ig:TemplateDataField Key="ClosedFindings">
<Header Text="ClosedFindings" />
<asp:Label ID="Label_ParentClosedFindings" runat="server" Text='<%# Eval("ClosedFindings") %>' Width="250px"></asp:Label>
<ig:TemplateDataField Key="Rating">
<Header Text="Rating" />
<asp:Label ID="Label_ParentRating" runat="server" Text="" Width="250px"></asp:Label>
<ig:TemplateDataField Key="AddControl">
<Header Text="Add Control" />
<asp:Button runat="server" ID="Button_ParentAddControl" CssClass="submitSmallButton" Text="Add"
ToolTip="Add Control" CausesValidation="false"></asp:Button>
</Columns>
<Bands>
<ig:Band AutoGenerateColumns="False" DataMember="Child1" Key="Bands" DataKeyFields="ID">
<ig:BoundDataField DataFieldName="FrameWorkName" Key="FrameWorkName">
<asp:Label ID="Label_Child1OpenFindings" runat="server" Text='<%# Eval("OpenFindings") %>'></asp:Label>
<asp:Label ID="Label_Child1ClosedFindings" runat="server" Text='<%# Eval("ClosedFindings") %>'></asp:Label>
<asp:Label ID="Label_Child1Rating" runat="server" Text=""></asp:Label>
<asp:Button runat="server" ID="Button_Child1AddControl" CssClass="submitSmallButton" Text="Add"
<ig:Band AutoGenerateColumns="False" DataMember="Child2" Key="Child2" DataKeyFields="ID">
<asp:Label ID="Label_Child2OpenFindings" runat="server" Text='<%# Eval("OpenFindings") %>'></asp:Label>
<asp:Label ID="Label_Child2ClosedFindings" runat="server" Text='<%# Eval("ClosedFindings") %>'></asp:Label>
<asp:Label ID="Label_Child2Rating" runat="server" Text=""></asp:Label>
<asp:Button runat="server" ID="Button_Child2AddControl" CssClass="submitSmallButton" Text="Add"
<ig:Band AutoGenerateColumns="False" DataMember="Child3" Key="Child3" DataKeyFields="ID">
<ig:TemplateDataField Key="Control">
<Header Text="Control" />
<asp:Label ID="Label_Control" runat="server" Text='<%# Eval("Control") %>'></asp:Label>
<asp:Label ID="Label_Child3OpenFindings" runat="server" Text='<%# Eval("OpenFindings") %>'></asp:Label>
<asp:Label ID="Label_Child3ClosedFindings" runat="server" Text='<%# Eval("ClosedFindings") %>'></asp:Label>
<ig:TemplateDataField Key="Result">
<Header Text="Result" />
<asp:Label ID="Label_Result" runat="server" Text=""></asp:Label>
<ig:TemplateDataField Key="Delete">
<Header Text="" />
<asp:LinkButton CommandArgument='<%# Bind("Id") %>' ID="LinkButton_Delete" OnClick="LinkButton_Delete_Click"
runat="server"><img src="../../static/images/trash_16x16.gif" width="12" height="11" alt="Delete Control" title="Delete Control" /></asp:LinkButton>
</ig:Band>
</Bands>
<Behaviors>
<ig:EditingCore EnableInheritance="true">
</ig:EditingCore>
</Behaviors>
</ig:WebHierarchicalDataGrid>
Parent:--------------0
Child1:----------0
Child2:-----------0
Child3-------2
Child4-------3
and i need like this
Parent:----------------9
Child1:-----------4
Child2:-----------5
Can you provide some more information, such as what type of data source you are binding your WHDG to ?