UltraWebGrid多表头的实现

  1. 首先在UltraWebGrid中设置好列,这里默认设置的列是col1,col2_1,col2_2,col3.其中col2_1和col2_2是要生成多表头的列。
  2. UltraWebGrid的InitializeLayout事件中写如下代码:

    // All the Headers for bound columns initialize to OriginX = 0.

    1. // Since we want them

    2. // to appear below the added column headers

    3. //we are going to need to move them down a level

    4. //先把所有列头都设为第二行

    5. foreach (Infragistics.WebUI.UltraWebGrid.UltraGridColumn

    6. ?c in UltraWebGrid1.DisplayLayout.Bands[0].Columns)

    7. {

    8. ?c.Header.RowLayoutColumnInfo.OriginY = 1;

    9. //纵向起始点,0为第一行,1为第二行

    10. }

    11. //创建一个列头对象

    12. var ch = new

    13. Infragistics.WebUI.UltraWebGrid.ColumnHeader(true);

    14. ch.Caption = "表头"; ? //列头文本标题

    15. ch.RowLayoutColumnInfo.OriginX = 1; ? //横向起始点,0为第一列,1为第二列

    16. ch.RowLayoutColumnInfo.OriginY = 0; ? //纵向起始点,0为第一行,1为第二行

    17. ch.RowLayoutColumnInfo.SpanX = 2; ? //设置横向跨度

    18. e.DisplayLayout.HeaderStyleDefault.Height = Unit.Pixel(15);

    19. e.Layout.Bands[0].HeaderLayout.Add(ch); //增加到列头集合中

    20. //把非多表头的列,进行跨行

    21. foreach (Infragistics.WebUI.UltraWebGrid.UltraGridColumn

    22. c in e.Layout.Bands[0].Columns)

    23. {

    24. ? if (c.Key != "col2_1" && c.Key != "col2_2")

    25. ?//c.Key 非多表头列的key值

    26. ? {

    27. ? ?c.Header.RowLayoutColumnInfo.OriginY = 0; //从第一行开始

    28. ? ?c.Header.RowLayoutColumnInfo.SpanY = 2; //跨2行

    29. ? ?}

    30. }

  3. 绑定数据源。只有在绑定数据源后,多表头格式才显示。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值