Reputation: 1
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
Upvotes: 0
Views: 2381
Reputation: 41
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
Upvotes: 0
Reputation: 17850
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;
Upvotes: 2