Code
1using System;
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using Infragistics.WebUI.UltraWebGrid;
12
13namespace UltraWebGrid
14{
15 public partial class _Default : System.Web.UI.Page
16 {
17 protected void Page_Load(object sender, EventArgs e)
18 {
19 if (!Page.IsPostBack)
20 {
21 //设置行号
22 UltraWebGrid1.DisplayLayout.AllowRowNumberingDefault = RowNumbering.ByBandLevel;
23 }
24 }
25
26 protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
27 {
28 //创建Tital列
29 e.Layout.Bands[0].Columns.FromKey("CompanyName").Move(0);
30 e.Layout.Bands[0].Columns.FromKey("CompanyName").Header.Caption = "企业名称";
31 e.Layout.Bands[0].Columns.FromKey("CurrAchieve").Move(1);
32 e.Layout.Bands[0].Columns.FromKey("CurrAchieve").Header.Caption = "本期累计完成";
33 e.Layout.Bands[0].Columns.FromKey("TogeAchieve").Move(2);
34 e.Layout.Bands[0].Columns.FromKey("TogeAchieve").Header.Caption = "同期累计完成";
35 //设置Y轴起始位置
36 foreach (UltraGridColumn col in e.Layout.Bands[0].Columns)
37 {
38 col.Header.RowLayoutColumnInfo.OriginY = 1;
39
40 }
41 //设定合并header
42 ColumnHeader colh;
43 colh = e.Layout.Bands[0].Columns.FromKey("CompanyName").Header;
44 colh.RowLayoutColumnInfo.OriginY = 0;
45 colh.RowLayoutColumnInfo.SpanY = 2;
46 //新建一个表头,设定它的名称
47 colh = new ColumnHeader(true);
48 colh.Caption = "营 业 收 入";
49 colh.Style.HorizontalAlign = HorizontalAlign.Center;
50 //设置X轴起始位置
51 colh.RowLayoutColumnInfo.OriginX = 1;
52 //设置该表头X轴方向占几列
53 colh.RowLayoutColumnInfo.SpanX = 2;
54 //将该表头加入到我们的Grid中
55 e.Layout.Bands[0].HeaderLayout.Add(colh);
56 //显示合计行
57 UltraWebGrid1.DisplayLayout.ColFootersVisibleDefault = ShowMarginInfo.Yes;
58 UltraWebGrid1.Columns[0].FooterText = "合 计:";
59 UltraWebGrid1.Columns[1].FooterTotal = SummaryInfo.Sum;
60 UltraWebGrid1.Columns[2].FooterTotal = SummaryInfo.Sum;
61 //格式设定
62 UltraWebGrid1.Columns[1].Format = "c2";
63 UltraWebGrid1.Columns[2].Format = "c2";
64 UltraWebGrid1.DisplayLayout.HeaderStyleDefault.HorizontalAlign = HorizontalAlign.Center;
65 UltraWebGrid1.Columns[0].CellStyle.HorizontalAlign = HorizontalAlign.Left;
66 UltraWebGrid1.Columns[1].CellStyle.HorizontalAlign = HorizontalAlign.Right;
67 UltraWebGrid1.Columns[2].CellStyle.HorizontalAlign = HorizontalAlign.Right;
68
69 }
70
71 protected void UltraWebGrid1_InitializeDataSource(object sender, UltraGridEventArgs e)
72 {
73 DataTable dt = new DataTable();
74 dt.Columns.Add("CompanyName");//企业名称
75 dt.Columns.Add("CurrAchieve", Type.GetType("System.Single"));//本期累计完成
76 dt.Columns.Add("TogeAchieve", Type.GetType("System.Single"));//同期累计完成
77 DataRow dr = dt.NewRow();
78 dr["CompanyName"] = "江苏迅达电磁线有限公司";
79 dr["CurrAchieve"] = "158000000";
80 dr["TogeAchieve"] = "160000000";
81 dt.Rows.Add(dr);
82
83 dr = dt.NewRow();
84 dr["CompanyName"] = "宝应县社会福利厂";
85 dr["CurrAchieve"] = "140000000";
86 dr["TogeAchieve"] = "120000000";
87 dt.Rows.Add(dr);
88
89 dr = dt.NewRow();
90 dr["CompanyName"] = "江苏苏中电缆厂";
91 dr["CurrAchieve"] = "110000000";
92 dr["TogeAchieve"] = "161000000";
93 dt.Rows.Add(dr);
94 //绑定数据源
95 UltraWebGrid1.DataSource = dt;
96
97 }
98 }
99}
100
1using System;
2using System.Data;
3using System.Configuration;
4using System.Collections;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8using System.Web.UI.WebControls;
9using System.Web.UI.WebControls.WebParts;
10using System.Web.UI.HtmlControls;
11using Infragistics.WebUI.UltraWebGrid;
12
13namespace UltraWebGrid
14{
15 public partial class _Default : System.Web.UI.Page
16 {
17 protected void Page_Load(object sender, EventArgs e)
18 {
19 if (!Page.IsPostBack)
20 {
21 //设置行号
22 UltraWebGrid1.DisplayLayout.AllowRowNumberingDefault = RowNumbering.ByBandLevel;
23 }
24 }
25
26 protected void UltraWebGrid1_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
27 {
28 //创建Tital列
29 e.Layout.Bands[0].Columns.FromKey("CompanyName").Move(0);
30 e.Layout.Bands[0].Columns.FromKey("CompanyName").Header.Caption = "企业名称";
31 e.Layout.Bands[0].Columns.FromKey("CurrAchieve").Move(1);
32 e.Layout.Bands[0].Columns.FromKey("CurrAchieve").Header.Caption = "本期累计完成";
33 e.Layout.Bands[0].Columns.FromKey("TogeAchieve").Move(2);
34 e.Layout.Bands[0].Columns.FromKey("TogeAchieve").Header.Caption = "同期累计完成";
35 //设置Y轴起始位置
36 foreach (UltraGridColumn col in e.Layout.Bands[0].Columns)
37 {
38 col.Header.RowLayoutColumnInfo.OriginY = 1;
39
40 }
41 //设定合并header
42 ColumnHeader colh;
43 colh = e.Layout.Bands[0].Columns.FromKey("CompanyName").Header;
44 colh.RowLayoutColumnInfo.OriginY = 0;
45 colh.RowLayoutColumnInfo.SpanY = 2;
46 //新建一个表头,设定它的名称
47 colh = new ColumnHeader(true);
48 colh.Caption = "营 业 收 入";
49 colh.Style.HorizontalAlign = HorizontalAlign.Center;
50 //设置X轴起始位置
51 colh.RowLayoutColumnInfo.OriginX = 1;
52 //设置该表头X轴方向占几列
53 colh.RowLayoutColumnInfo.SpanX = 2;
54 //将该表头加入到我们的Grid中
55 e.Layout.Bands[0].HeaderLayout.Add(colh);
56 //显示合计行
57 UltraWebGrid1.DisplayLayout.ColFootersVisibleDefault = ShowMarginInfo.Yes;
58 UltraWebGrid1.Columns[0].FooterText = "合 计:";
59 UltraWebGrid1.Columns[1].FooterTotal = SummaryInfo.Sum;
60 UltraWebGrid1.Columns[2].FooterTotal = SummaryInfo.Sum;
61 //格式设定
62 UltraWebGrid1.Columns[1].Format = "c2";
63 UltraWebGrid1.Columns[2].Format = "c2";
64 UltraWebGrid1.DisplayLayout.HeaderStyleDefault.HorizontalAlign = HorizontalAlign.Center;
65 UltraWebGrid1.Columns[0].CellStyle.HorizontalAlign = HorizontalAlign.Left;
66 UltraWebGrid1.Columns[1].CellStyle.HorizontalAlign = HorizontalAlign.Right;
67 UltraWebGrid1.Columns[2].CellStyle.HorizontalAlign = HorizontalAlign.Right;
68
69 }
70
71 protected void UltraWebGrid1_InitializeDataSource(object sender, UltraGridEventArgs e)
72 {
73 DataTable dt = new DataTable();
74 dt.Columns.Add("CompanyName");//企业名称
75 dt.Columns.Add("CurrAchieve", Type.GetType("System.Single"));//本期累计完成
76 dt.Columns.Add("TogeAchieve", Type.GetType("System.Single"));//同期累计完成
77 DataRow dr = dt.NewRow();
78 dr["CompanyName"] = "江苏迅达电磁线有限公司";
79 dr["CurrAchieve"] = "158000000";
80 dr["TogeAchieve"] = "160000000";
81 dt.Rows.Add(dr);
82
83 dr = dt.NewRow();
84 dr["CompanyName"] = "宝应县社会福利厂";
85 dr["CurrAchieve"] = "140000000";
86 dr["TogeAchieve"] = "120000000";
87 dt.Rows.Add(dr);
88
89 dr = dt.NewRow();
90 dr["CompanyName"] = "江苏苏中电缆厂";
91 dr["CurrAchieve"] = "110000000";
92 dr["TogeAchieve"] = "161000000";
93 dt.Rows.Add(dr);
94 //绑定数据源
95 UltraWebGrid1.DataSource = dt;
96
97 }
98 }
99}
100