I am using the master detail xtragrid and want to make the total sum of all detail gridview and populate in the footer of master gridview
Asked
Active
Viewed 2,343 times
2 Answers
2
I suggest you show the detail summary information in an additional column in a master row as described in the How to display a summary calculated over detail rows in a master grid view column example:
//...
GridColumn colSubTotal = gridView1.Columns.AddField("SubTotal");
colSubTotal.UnboundType = DevExpress.Data.UnboundColumnType.Integer;
colSubTotal.Visible = true;
colSubTotal.Caption = "Budget";
gridView1.CustomUnboundColumnData += gridView1_CustomUnboundColumnData;
//...
void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
GridView view = sender as GridView;
if(e.Column.FieldName != "SubTotal") return;
if(!e.IsGetData) return;
DataRow row = ((view.DataSource as IList)[e.ListSourceRowIndex] as DataRowView).Row;
int subTotal = 0;
foreach(DataRow childRow in row.GetChildRows("Project_Tasks"))
subTotal += (int)childRow["Budget"];
e.Value = subTotal;
}
Then show the total summary for all details by specifying a summary for this additional column:
colSubTotal.Summary.Add(DevExpress.Data.SummaryItemType.Sum);
gridView1.OptionsView.ShowFooter = true;

DmitryG
- 17,677
- 1
- 30
- 53
-
i have done every thing but CustomUnboundColumnData event is not being fired – Usman Hussain Mar 05 '13 at 15:13
-
@UsmanHussain Please, download the sample which i've mentioned above and modify the code like it demonstrated in my answer. All things should works as expected (I've checked this before posting the answer). – DmitryG Mar 05 '13 at 15:22
-
Dear thank u so much.You provided me a great work that's very beneficial for me thank you very much – Usman Hussain Mar 05 '13 at 18:04
-
@UsmanHussain I am happy to hear that my assistance was helpful to you. But you [should always](http://stackoverflow.com/faq#howtoask) accept the correct answers and vote for helpful posts instead of thanks – DmitryG Mar 06 '13 at 06:58
0
set showfooter property of gridview in aspx page as true. In Grid_DataBound event of gridview for footer row, make column span of first cell of footer row equal to total number of columns in the grid and make rest of cells except 2 as invisible. add text to first cell of footer row

meghna
- 41
- 6