T
Tumurbaatar S.
Can anybody help me to make my DataGrid header
like below one?
--------------------------------------
| | | SomeText
H1| H2 | H3 | -------------------
| | | H4 | H5 | H6
--------------------------------------
In the plain HTML, this can be achieved using RowSpan and ColumnSpan
attributes. But how to apply it to the DataGrid?
I have some experience in manipulating a DataGrid content from a code.
So I decided to add one extra header row below the existing one and thru
modifying theirs cells, get what I need. But my test code failed at a very
first step!
I called below code from DataGrid_Prerender and instead of getting an extra
header row with a text "test", I got an empty row. Without <td> elements
inside!
//this fragment from browser's Source View
<tr
style="color:White;background-color:#006699;font-size:8pt;font-weight:bold;">
</tr>
//the code from Grid_Prerender()
DataGridItem hdr = null, sub;
TableCell cell;
int c;
for (c = 0; c < Grid.Controls[0].Controls.Count; c++)
{
hdr = Grid.Controls[0].Controls[c] as DataGridItem;
if (hdr != null && hdr.ItemType == ListItemType.Header)
break;
}
if (hdr == null || hdr.ItemType != ListItemType.Header)
return;
sub = new DataGridItem(-1, -1, ListItemType.Header);
cell = new TableCell();
cell.ColumnSpan = hdr.Cells.Count;
cell.Text = "test";
sub.Cells.Add(cell);
Grid.Controls[0].Controls.AddAt(c + 1, sub);
If above problem will be solved, my next step is to try to
create/move/rowspan/colspan
cells from above 2 header rows and, may be, I will get some result.
like below one?
--------------------------------------
| | | SomeText
H1| H2 | H3 | -------------------
| | | H4 | H5 | H6
--------------------------------------
In the plain HTML, this can be achieved using RowSpan and ColumnSpan
attributes. But how to apply it to the DataGrid?
I have some experience in manipulating a DataGrid content from a code.
So I decided to add one extra header row below the existing one and thru
modifying theirs cells, get what I need. But my test code failed at a very
first step!
I called below code from DataGrid_Prerender and instead of getting an extra
header row with a text "test", I got an empty row. Without <td> elements
inside!
//this fragment from browser's Source View
<tr
style="color:White;background-color:#006699;font-size:8pt;font-weight:bold;">
</tr>
//the code from Grid_Prerender()
DataGridItem hdr = null, sub;
TableCell cell;
int c;
for (c = 0; c < Grid.Controls[0].Controls.Count; c++)
{
hdr = Grid.Controls[0].Controls[c] as DataGridItem;
if (hdr != null && hdr.ItemType == ListItemType.Header)
break;
}
if (hdr == null || hdr.ItemType != ListItemType.Header)
return;
sub = new DataGridItem(-1, -1, ListItemType.Header);
cell = new TableCell();
cell.ColumnSpan = hdr.Cells.Count;
cell.Text = "test";
sub.Cells.Add(cell);
Grid.Controls[0].Controls.AddAt(c + 1, sub);
If above problem will be solved, my next step is to try to
create/move/rowspan/colspan
cells from above 2 header rows and, may be, I will get some result.