我正在使用主详细信息xtragrid并希望制作所有详细网格视图的总和并填充在主网格视图的页脚中
答案 0 :(得分:2)
我建议您在主排的其他列中显示详细摘要信息,如How to display a summary calculated over detail rows in a master grid view column示例中所述:
//...
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;
}
然后通过指定此附加列的摘要显示所有详细信息的总摘要:
colSubTotal.Summary.Add(DevExpress.Data.SummaryItemType.Sum);
gridView1.OptionsView.ShowFooter = true;
答案 1 :(得分:0)
将aspx页面中gridview的showfooter属性设置为true。 在gridview的Grid_DataBound事件中 对于页脚行,使页脚行的第一个单元格的列跨度等于网格中的总列数,并使除2之外的其余单元格不可见。 将文本添加到页脚行的第一个单元格