Hi i am facing a problem with custom summary row in second band of the WHDG. My Grid HTML is as follow
<ig:WebHierarchicalDataGrid id="grdElementaryTranscript" runat="server" height="400px" width="1000px" DataKeyFields="StudentID" AutoGenerateColumns="false" autoGenerateBands="True" InitialExpandDepth="0" onpageindexchanged="grdElementaryTranscript_PageIndexChanged" InitialDataBindDepth="-1" OnCalculateCustomSummary="grdElementaryTranscript_CalculateCustomSummary" EnableDataViewState="true"> <Behaviors> <ig:Selection RowSelectType="Single" Enabled="true" CellClickAction="Row" /> <ig:Paging PagerAppearance="Bottom" PageSize="10" Enabled="true" /> <ig:RowSelectors Enabled="true" RowNumbering="false" /> <ig:Filtering Enabled="false" /> <ig:Sorting Enabled="false" /> </Behaviors> <Columns> <ig:BoundDataField DataFieldName="StudentID" Key="StudentID" Header-Text="Student ID" Hidden="true"> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Name" Key="Name" Header-Text="Name" Width="100px"> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Email" Key="Email" Header-Text="Email" Width="100px"> </ig:BoundDataField> <ig:BoundDataField DataFieldName="BirthDate" Key="BirthDate" Header-Text="Birth Date"> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Address" Key="Address" Header-Text="Address"> </ig:BoundDataField> <ig:BoundDataField DataFieldName="RegistrationNo" Key="RegistrationNo" Header-Text="Registration No"> </ig:BoundDataField> <ig:BoundDataField DataFieldName="RegistrationDate" Key="RegistrationDate" Header-Text="Registration Date"> </ig:BoundDataField> <ig:BoundCheckBoxField DataFieldName="isActive" Key="isActive" Header-Text="Active"></ig:BoundCheckBoxField> </Columns> <Bands> <ig:Band DataMember="Subjects" Key="Subjects" DataKeyFields="SubjectID" AutoGenerateColumns="false"> <Columns> <ig:BoundDataField DataFieldName="SubjectID" Key="SubjectID" Header-Text="Subject ID" Hidden="true"> </ig:BoundDataField> <ig:BoundDataField DataFieldName="StudentID" Key="StudentID" Header-Text="StudentID" width="150px"></ig:BoundDataField> <ig:BoundDataField DataFieldName="SubjectName" Key="SubjectName" Header-Text="Subject Name" width="100px"></ig:BoundDataField> <ig:BoundDataField DataFieldName="ClassCreditUnits" Key="ClassCreditUnits" Header-Text="Credits" width="100px"></ig:BoundDataField> <ig:BoundDataField DataFieldName="Marks" Key="Marks" Header-Text="Marks" width="100px"></ig:BoundDataField> <ig:BoundDataField DataFieldName="Sem10n" Key="Sem10n" Header-Text="Sem10n" width="100px"> </ig:BoundDataField> </Columns> <Behaviors> <ig:SummaryRow AnimationType="Bounce" Enabled="true"> <ColumnSummaries> <ig:ColumnSummaryInfo ColumnKey="ClassCreditUnits"> <Summaries> <ig:Summary SummaryType="Custom" CustomSummaryName="GPA" /> </Summaries> </ig:ColumnSummaryInfo> <ig:ColumnSummaryInfo ColumnKey="Marks"> <Summaries> <ig:Summary SummaryType="Custom" CustomSummaryName="Percentage" /> </Summaries> </ig:ColumnSummaryInfo> <ig:ColumnSummaryInfo ColumnKey="Sem10n"> <Summaries> <ig:Summary SummaryType="Custom" CustomSummaryName="StDev" /> </Summaries> </ig:ColumnSummaryInfo> </ColumnSummaries> <ColumnSettings> <ig:SummaryRowSetting ColumnKey="ClassCreditUnits"> <SummarySettings> <ig:SummarySetting CustomSummaryName="GPA" SummaryType="Custom" /> </SummarySettings> </ig:SummaryRowSetting> <ig:SummaryRowSetting ColumnKey="Marks"> <SummarySettings> <ig:SummarySetting CustomSummaryName="Percentage" SummaryType="Custom" /> </SummarySettings> </ig:SummaryRowSetting> <ig:SummaryRowSetting ColumnKey="Sem10n"> <SummarySettings> <ig:SummarySetting CustomSummaryName="StDev" SummaryType="Custom" /> </SummarySettings> </ig:SummaryRowSetting> </ColumnSettings> </ig:SummaryRow> </Behaviors> </ig:Band> </Bands> </ig:webhierarchicaldatagrid>
I am binding the grid using a LoadGridData method which is called on a button click
private void LoadGridData() { blStudent objData = new blStudent(); DataTable dt = objData.GetStudentList(); blSubject objSubject = new blSubject(); DataTable dt2 = objSubject.GetSubjectList(); dsStudent.Tables.Add(dt); dsStudent.Tables.Add(dt2); dsStudent.Tables[0].TableName = "Students"; dsStudent.Tables[1].TableName = "Subjects"; dsStudent.Relations.Add("rlnStudent", dsStudent.Tables["Students"].Columns["StudentID"], dsStudent.Tables["Subjects"].Columns["StudentID"], false); //DataView MsDataView = dsStudent.Tables[0].DefaultView; grdElementaryTranscript.DataSource = dsStudent; grdElementaryTranscript.DataBind(); }
I have write an event which calculte custom summary row in webdatagrid i used it in WHDG as it is.
protected object grdElementaryTranscript_CalculateCustomSummary(object sender, Infragistics.Web.UI.GridControls.CustomSummaryEventArgs e) { // calculate the total budget variance % if (e.Summary.CustomSummaryName == "GPA") { //calculate the sum of all values double decASum = 10.0; double decBSum = 2.0; double decPercentDifference; switch (e.ColumnSummaryInfo.ColumnKey) { case "ClassCreditUnits": decPercentDifference = decBSum / decASum; return decPercentDifference; case "Marks": decPercentDifference = decBSum / decASum; return decPercentDifference; case "Sem10n": decPercentDifference = decBSum / decASum; return decPercentDifference; default: return null; } } return null; }
But i have got an exception that CalculateCustomSummary event must be handeled in order to use custom summaries.
How should i write custom summary in the WebHierarchichalDataGrid in second band.
i am keenly looking for solution
Thanks
Akhtar Abbas
.NET Developer
Hello Akhtar,
I am glad that I've managed to help you.
Please refer to the following article => http://help.infragistics.com/Help/Doc/ASPNET/2015.1/CLR4.0/html/WebDataGrid_Adding_Custom_Summary.html
You can access the grid for current from the sender argument by casting to WebDataGrid.
Let me know if I can help you with anything else.
Thanks Denis Georgiev
this solved my problem.
Now i have issue that how should i loop on the band column to get the record of that column to perform certain calculations?????
in the CalculateCustomSummary event??
Thank you for contacting Infragistics!
You have defined handler in your parent grid
Akhtar Abbas said: <ig:WebHierarchicalDataGrid id="grdElementaryTranscript" runat="server" height="400px" width="1000px" DataKeyFields="StudentID" AutoGenerateColumns="false" autoGenerateBands="True" InitialExpandDepth="0" onpageindexchanged="grdElementaryTranscript_PageIndexChanged" InitialDataBindDepth="-1" OnCalculateCustomSummary="grdElementaryTranscript_CalculateCustomSummary" EnableDataViewState="true">
In order to have a custom summary for the band you should handle the event inside the band tag:
<ig:Band DataMember="Subjects" Key="Subjects" DataKeyFields="SubjectID" AutoGenerateColumns="false" OnCalculateCustomSummary="grdElementaryTranscript_CalculateCustomSummary">
Let me know if you need further assistance.