컬럼 포물러지정해서 계산결과 보여주고
Footer 에 Total 출력하는 소스 부분이다. avg도 있다.
[CODE]
protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
{
// set up the Total line item of the WebGrid
e.Layout.Bands[0].Columns.Add("Total","Total");
Infragistics.WebUI.UltraWebGrid.UltraGridColumn c = e.Layout.Bands[0].Columns.FromKey("Total");
c.DataType = "System.Double";
c.Format = "C";
c.Width = Unit.Pixel(150);
c.CellStyle.HorizontalAlign = HorizontalAlign.Right;
// set up footer summaries for total column
c.Footer.Key = "Total";
c.Footer.Caption = "Total = ";
c.Footer.Total = Infragistics.WebUI.UltraWebGrid.SummaryInfo.Sum;
c.Footer.Formula = "ROUND(SUM([Total]),2)";
// set up footer summaries for the Unit Price column
c = e.Layout.Bands[0].Columns.FromKey("UnitPrice");
c.Width = Unit.Pixel(150);
c.Header.Caption = "Unit Price";
c.CellStyle.HorizontalAlign = HorizontalAlign.Right;
c.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes;
c.Format = "###,###,###.00";
Infragistics.WebUI.UltraWebGrid.ColumnFooter cf = c.Footer ;
cf.Key = "UnitPrice";
cf.Caption = "Average Price = ";
cf.Total = Infragistics.WebUI.UltraWebGrid.SummaryInfo.Avg;
cf.Formula = "ROUND(AVG([UnitPrice]),2)";
// set up footer summaries for Number Sold
c = e.Layout.Bands[0].Columns.FromKey("NumberSold");
c.Width = Unit.Pixel(150);
c.CellStyle.HorizontalAlign = HorizontalAlign.Right;
c.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes;
c.Format = "###,###,###";
cf = c.Footer;
cf.Key = "NumberSold";
cf.Caption = "Total Items Sold = ";
cf.Total = Infragistics.WebUI.UltraWebGrid.SummaryInfo.Sum;
cf.Formula = "SUM([NumberSold])";
// Allow for footers to be visible
Infragistics.WebUI.UltraWebGrid.UltraGridBand b = UltraWebGrid1.Bands[0];
b.ColFootersVisible = Infragistics.WebUI.UltraWebGrid.ShowMarginInfo.Yes;
// set up footer style
//e.Layout.FooterStyleDefault.BackColor = Color.y
}
[/CODE]
이소스부분을 조금 고쳐서 나에 맞게 수정해서 테스트 해보았다.
소스가 지져분해도 우선은 그냥 익히는 데 중점을 두자..
[CODE]
UltraWebGrid1.Bands[0].Columns.Add("Total", "ba_ulimit * 5 = ?");
Infragistics.WebUI.UltraWebGrid.UltraGridColumn c = UltraWebGrid1.Bands[0].Columns.FromKey("Total");
c.DataType = "System.Double";
c.Format = "C";
c.Formula = " [ba_ulimit] * 5 ";
c.Width = Unit.Pixel(150);
c.CellStyle.HorizontalAlign = HorizontalAlign.Right;
// set up footer summaries for total column
c.Footer.Key = "Total";
c.Footer.Caption = "Total = ";
c.Footer.Total = Infragistics.WebUI.UltraWebGrid.SummaryInfo.Sum;
c.Footer.Formula = "ROUND(SUM([Total]),2)";
// set up footer summaries for the Unit Price column
c = UltraWebGrid1.Bands[0].Columns.FromKey("ba_ulimit");
c.Width = Unit.Pixel(150);
//c.Header.Caption = "ba_ulimit Value";
c.CellStyle.HorizontalAlign = HorizontalAlign.Right;
c.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes;
//c.Format = "###,###,###.00";
Infragistics.WebUI.UltraWebGrid.ColumnFooter cf = c.Footer;
cf.Key = "ba_bcode";
cf.Caption = "ba_bcode value = ";
cf.Total = Infragistics.WebUI.UltraWebGrid.SummaryInfo.Avg;
cf.Formula = "ROUND(SUM([ba_bcode]),2)";
// Allow for footers to be visible
Infragistics.WebUI.UltraWebGrid.UltraGridBand b = UltraWebGrid1.Bands[0];
b.ColFootersVisible = Infragistics.WebUI.UltraWebGrid.ShowMarginInfo.Yes;
//이렇게해도 ?
//UltraWebGrid1.DisplayLayout.ColFootersVisibleDefault = ShowMarginInfo.Yes;
//UltraWebGrid1.DisplayLayout.Bands[0].Columns.FromKey("ba_ulimit").Footer.Total = SummaryInfo.Sum;
[/CODE]
그리고 #VALUE! 라는 에러메세지가 뜨지 않게 하기 위해서는
[CODE]
this.UltraWebGrid1.DisplayLayout.AddNewBox.Hidden = false;
this.UltraWebGrid1.DisplayLayout.AllowAddNewDefault = AllowAddNew.Yes;
//this.UltraWebGrid1.DisplayLayout.CellClickActionDefault = CellClickAction.Edit;
this.UltraWebGrid1.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes;
[/CODE]
이렇게 코드를 추가해주어야 버튼클릭시 새로운 로우추가를 허용해준다.
#VALUE! 가 왜 뜨는 가?
It usually means that the expression you are using to generate the value you are trying to display is generating an invalid value. I'd start by looking for "divide by zero", type mismatches, etc.
포럼에서 이렇게 설명해주더라. 일반적으로는 0으로 나누거나 값에 문제가 있을때 겠지 ~