Hi,
I'm building a grid dynamically from several database tables.
Tables:
* Groups (used to group columns)
* Columns
And datatables, to support data in the structure.
One column can only be member of one group.. but a group can contain several columns.
In the Grid this will be viewed with two column headers, where the group header uses columnspan to span over the columns within the group.
A column contains datatype, format, width and alignment.
So far so good...
I managed to create a grid looking like it should with the column headers and groupheaders. I used the PreRender event to add a second header.
I also added all necessary data to the extendedproperties on the datatable (the datatable is dynamically buildt to support the dynamic setup). So this would be available for me when rendering the grid.
But my problem starts when i wanted to format the data within the cells/columns. One of the column had the type DateTime and the format "{0:dd.MM}" (want to show day and month only). I tried to set the DataFormatString in the PreRender Event for the column, but it still shows the whole date and time.
How can i solve this? This is the code i hardcoded into the prerender event to test this:
I'm not able to set the alignment for the column either. I can set it for the columnheaders, but i think that is because i have the cell object for each header. I want to be able to set both the format and the alignment for the column some place...
Some of the columns can have a flag saying that if the value drops below zero we want to display zero or blank. Is there anywhere this can be set. And remember, i don't know the name of the column before runtime.
And one other thing: How can i add a "grand total" row at the end summarizing only the columns marked for it? (eg: column3, column4 and column5 should be summarized, but not column1 and column2).
Regards
Svein Thomas
I'm building a grid dynamically from several database tables.
Tables:
* Groups (used to group columns)
* Columns
And datatables, to support data in the structure.
One column can only be member of one group.. but a group can contain several columns.
In the Grid this will be viewed with two column headers, where the group header uses columnspan to span over the columns within the group.
A column contains datatype, format, width and alignment.
So far so good...
I managed to create a grid looking like it should with the column headers and groupheaders. I used the PreRender event to add a second header.
I also added all necessary data to the extendedproperties on the datatable (the datatable is dynamically buildt to support the dynamic setup). So this would be available for me when rendering the grid.
But my problem starts when i wanted to format the data within the cells/columns. One of the column had the type DateTime and the format "{0:dd.MM}" (want to show day and month only). I tried to set the DataFormatString in the PreRender Event for the column, but it still shows the whole date and time.
How can i solve this? This is the code i hardcoded into the prerender event to test this:
((GridBoundColumn)RadGrid1.MasterTableView.GetColumn(
"to.date"
)).DataType = Type.GetType(
"System.DateTime"
);
((GridBoundColumn)RadGrid1.MasterTableView.GetColumn(
"to.date"
)).DataFormatString =
"{0:dd.MM}"
;
I'm not able to set the alignment for the column either. I can set it for the columnheaders, but i think that is because i have the cell object for each header. I want to be able to set both the format and the alignment for the column some place...
Some of the columns can have a flag saying that if the value drops below zero we want to display zero or blank. Is there anywhere this can be set. And remember, i don't know the name of the column before runtime.
And one other thing: How can i add a "grand total" row at the end summarizing only the columns marked for it? (eg: column3, column4 and column5 should be summarized, but not column1 and column2).
Regards
Svein Thomas