技术开发 频道

ASPxGridView的多表头功能实现技巧

  band = GetNewTableCell(row, bandname);

  }

  col.Caption
= col.FieldName.Substring(col.FieldName.IndexOf("|") + 1);

  band.ColumnSpan
++;

  }

  
else

  {

  firstBand.ColumnSpan
++;

  }

  }

  table.Rows.AddAt(
0, row);

  }

  }

  }

  
//可以在此修改单元格样式

  
private static TableCell GetNewTableCell(TableRow row, string bandname)

  {

  TableCell band
= new TableCell();

  band.Text
= bandname;

  row.Cells.Add(band);

  band.CssClass
= "dxgvHeader";

  band.HorizontalAlign
= HorizontalAlign.Center;

  band.BorderStyle
= BorderStyle.NotSet;

  band.BorderColor
= row.BorderColor;

  return band;

  }

  注意:

  1、该方法在绑定方法之前调用。

  2、需合并的单元格的 列需如下设置:

<dx:GridViewDataTextColumn Caption="合计|重号" VisibleIndex="0" FieldName="合计|重号">

                               </dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="合计|缺号" VisibleIndex="0" FieldName="合计|缺号">
                               </dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn Caption="合计|错号" VisibleIndex="0" FieldName="合计|错号"><BR>                                </dx:GridViewDataTextColumn>

 

按照“|”分割判断,相同的则会总动合并。<BR><BR><BR>
0
相关文章