Hi,
I need to know how can I prepare dynamic crosstab report. I used code from examples. But it's generate only header row and one data row.
I need to know how can I prepare dynamic crosstab report. I used code from examples. But it's generate only header row and one data row.
private
void
crosstab1_ItemDataBinding(
object
sender, EventArgs e)
{
//Connections and commands
.....
//get the processing table object since we're in the context of event
Telerik.Reporting.Processing.Table processingTable = (sender
as
Telerik.Reporting.Processing.Table);
//construct the select statement based on the selected report parameters
SqlDataAdapter sqlAdapter =
new
SqlDataAdapter(sComm);
sqlAdapter.SelectCommand.CommandTimeout = 3600;
//create a dataset, fill it and set it as datasource to the processing table object
DataSet ds =
new
DataSet();
sqlAdapter.Fill(ds);
processingTable.DataSource = ds.Tables[0];
//create two HtmlTextBox items (one for header and one for data) which would be added to the items collection of the table
Telerik.Reporting.HtmlTextBox textboxGroup;
Telerik.Reporting.HtmlTextBox textBoxTable;
//we do not clear the Rows collection, since we have a details row group and need to create columns only
this
.crosstab1.ColumnGroups.Clear();
this
.crosstab1.Body.Columns.Clear();
this
.crosstab1.Body.Rows.Clear();
int
i = 0;
this
.crosstab1.ColumnHeadersPrintOnEveryPage =
true
;
DataTable dt = ds.Tables[0];
foreach
(DataColumn dc
in
dt.Columns)
{
Telerik.Reporting.TableGroup tableGroupColumn =
new
Telerik.Reporting.TableGroup();
this
.crosstab1.ColumnGroups.Add(tableGroupColumn);
this
.crosstab1.Body.Columns.Add(
new
Telerik.Reporting.TableBodyColumn(Unit.Inch(1)));
textboxGroup =
new
Telerik.Reporting.HtmlTextBox();
textboxGroup.Style.BorderColor.Default = Color.Black;
textboxGroup.Style.BorderStyle.Default = BorderType.Solid;
textboxGroup.Value = dc.ColumnName;
textboxGroup.Size =
new
SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
tableGroupColumn.ReportItem = textboxGroup;
textBoxTable =
new
Telerik.Reporting.HtmlTextBox();
textBoxTable.Style.BorderColor.Default = Color.Black;
textBoxTable.Style.BorderStyle.Default = BorderType.Solid;
textBoxTable.Value =
"=Fields."
+ dc.ColumnName;
textBoxTable.Size =
new
SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
this
.crosstab1.Body.SetCellContent(0, i++, textBoxTable);
this
.crosstab1.Items.AddRange(
new
ReportItemBase[] { textBoxTable, textboxGroup });
}
}