Merging columns in GridView/DataGrid header
来源:互联网 发布:mysql 安全模式 编辑:程序博客网 时间:2024/05/01 04:15
Background
As necessity to show header columns in a few rows occurs fairly often it would be good to have such functionality in the GridView/DataGrid
control as an in-built feature. But meanwhile everyone solves this problem in his own way.
The described below variant of the merging implementation is based on irwansyah's idea to use the SetRenderMethodDelegate
method for custom rendering of grid columns header. I guess this approach can be simplified in order to get more compact and handy code for reuse.
The code overview
As it may be required to merge a few groups of columns - for example, 1,2 and 4,5,6 - we need a class to store common information about all united columns.
Attribute Serializable
is added in order to have a possibility to store information about merged columns in ViewState - it is required if paging or sorting is used.
That is the only additional action. Now the code usage.
file:
.ascx
Columns can be defined in design time or can be auto generated - it does not matter and doesn't influence the further code. Merging also does not harm sorting and paging if they are used in the GridView/DataGrid.
file:
.cs
Particular code for GridView:
and for DataGrid:
Next code is common for both GridView and DataGrid:
That is all. The code can be used without any modification, the only part that has to be changed in a concrete case is:
From http://marss.co.ua/MergingGridViewHeaderColumns.aspx
好东东,先与各位分享,有时间再翻译.
- Merging columns in GridView/DataGrid header
- Editable GridView - All Columns in GridView are Editable
- DPC:Hiding Columns In A DataGrid[等级:初 中]
- Dynamically Creating Bound and Template Columns in GridView
- GridView.Columns 属性
- Freeze Table Header and Columns
- Merging PDF Files in Cocoa
- Dragging and Dropping DataGrid Columns
- Dragging and Dropping DataGrid Columns
- Creating DataGrid Templated Columns Dynamically -
- Dynamically creating bound and template columns in GridView using ASP.Net
- WPF DataGrid DataGrid.Columns 使用笔记
- GridView DataGrid
- DataGrid GridView
- Silverlight DataGrid Multi Header
- Creating DataGrid Templated Columns Dynamically - Part I
- Creating DataGrid Templated Columns Dynamically - Part II
- 使用easyUI 动态改变datagrid的columns
- 第五章--JXTA协议
- 第二.CUDA的环境搭建----32位版本与64位版本的迷茫
- 有一种恩情你或永世不知
- 发布bbossgroups-2.0-RC补丁-bboss rpc classcast and timeout exception patch.zip
- JSTL 学习2 - 2
- Merging columns in GridView/DataGrid header
- VC6头文件引用问题多多啊
- access和SQL的语法区别
- 显式调用析构函数
- 从零开始实现一个电子商务网站
- 生活
- MP3文件格式与编码原理解码流程详解
- C语言声明的分析方法
- python笔记1