Hi,
I have one detail section within a group section containing one textbox bound to a datafield called projNr.
For each group item I would normally have several of rows with projNr.
How can I show these in a multicolumn table or such so that the number of pages decreases?
Is the table component my best shot or should I format my data in code behind into a htmltextbox instead?
Looking forward to an answer!
Thanks,
Per
I have one detail section within a group section containing one textbox bound to a datafield called projNr.
For each group item I would normally have several of rows with projNr.
How can I show these in a multicolumn table or such so that the number of pages decreases?
Is the table component my best shot or should I format my data in code behind into a htmltextbox instead?
Looking forward to an answer!
Thanks,
Per
4 Answers, 1 is accepted
0
Per
Top achievements
Rank 1
answered on 23 Oct 2013, 07:59 AM
Here's my first attempt trying to populate a report table from by binding it to a DataTable in code behind.
No data is shown in the report table.
Could someone at Telerik please answer, this is very urgent!
Here's my table definition taken from the auto-generated code by the designer:
Code trying to bind table1 to a DataTable:
No data is shown in the report table.
Could someone at Telerik please answer, this is very urgent!
Here's my table definition taken from the auto-generated code by the designer:
this.table1 = new Telerik.Reporting.Table();
// table1
//
this.table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Cm(1.9804118871688843D)));
this.table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Cm(1.9804122447967529D)));
this.table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Cm(2.056462287902832D)));
this.table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Cm(1.9506288766860962D)));
this.table1.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(Telerik.Reporting.Drawing.Unit.Cm(2.0829212665557861D)));
this.table1.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(Telerik.Reporting.Drawing.Unit.Cm(0.52000051736831665D)));
this.table1.Body.SetCellContent(0, 0, this.textBox2);
this.table1.Body.SetCellContent(0, 1, this.textBox7);
this.table1.Body.SetCellContent(0, 2, this.textBox11);
this.table1.Body.SetCellContent(0, 4, this.textBox13);
this.table1.Body.SetCellContent(0, 3, this.textBox15);
tableGroup1.Name = "tableGroup";
tableGroup1.ReportItem = this.textBox1;
tableGroup2.Name = "tableGroup1";
tableGroup2.ReportItem = this.textBox6;
tableGroup3.Name = "group";
tableGroup3.ReportItem = this.textBox10;
tableGroup4.Name = "group2";
tableGroup4.ReportItem = this.textBox14;
tableGroup5.Name = "group1";
tableGroup5.ReportItem = this.textBox12;
this.table1.ColumnGroups.Add(tableGroup1);
this.table1.ColumnGroups.Add(tableGroup2);
this.table1.ColumnGroups.Add(tableGroup3);
this.table1.ColumnGroups.Add(tableGroup4);
this.table1.ColumnGroups.Add(tableGroup5);
this.table1.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.textBox1,
this.textBox2,
this.textBox6,
this.textBox7,
this.textBox10,
this.textBox11,
this.textBox12,
this.textBox13,
this.textBox14,
this.textBox15});
this.table1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Cm(5.019587516784668D), Telerik.Reporting.Drawing.Unit.Cm(8.3104639053344727D));
this.table1.Name = "table1";
tableGroup6.Groupings.Add(new Telerik.Reporting.Grouping(null));
tableGroup6.Name = "detailTableGroup";
this.table1.RowGroups.Add(tableGroup6);
this.table1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Cm(10.050835609436035D), Telerik.Reporting.Drawing.Unit.Cm(1.0400010347366333D));
this.table1.NeedDataSource += new System.EventHandler(this.table1_NeedDataSource);
Code trying to bind table1 to a DataTable:
public static List<
string
> _projectsAffected = new List<
string
>();
private void table1_NeedDataSource(object sender, EventArgs e)
{
DataTable dt = new DataTable();
DataColumn c1 = new DataColumn();
DataColumn c2 = new DataColumn();
DataColumn c3 = new DataColumn();
DataColumn c4 = new DataColumn();
DataColumn c5 = new DataColumn();
DataRow r;
dt.Columns.Add(c1);
dt.Columns.Add(c2);
dt.Columns.Add(c3);
dt.Columns.Add(c4);
dt.Columns.Add(c5);
for (int i = 0; i <
_projectsAffected.Count
; i++)
{
r
=
dt
.NewRow();
for (int
j
=
0
; j < 5; j++)
{
if (i >= _projectsAffected.Count)
break;
r[j] = _projectsAffected[i];
i++;
}
i -= 1;
dt.Rows.Add(r);
}
(sender as Telerik.Reporting.Processing.Table).DataSource = dt;
_projectsAffected.Clear();
}
private void detail_ItemDataBinding(object sender, EventArgs e)
{
Telerik.Reporting.Processing.DetailSection section = (sender as Telerik.Reporting.Processing.DetailSection);
Telerik.Reporting.Processing.TextBox txt = (Telerik.Reporting.Processing.TextBox)Telerik.Reporting.Processing.ElementTreeHelper.GetChildByName(section, "txtProjectsAffected");
object projDef = section.DataObject["ProjectDefinition"];
_projectsAffected.Add((string)projDef);
}
0
Hi,
You can find attached a sample project illustrating a Table item bound as in your code snippet.
In addition, take a look at the following forum post, elaborating on another approach to arrange the data as described: How to show detail data to across then down?
If it is an emergency or you need any further help, please use our support ticketing system, where your questions will be answered in a timely manner according to your support subscription plan.
Regards,
Stef
Telerik
You can find attached a sample project illustrating a Table item bound as in your code snippet.
In addition, take a look at the following forum post, elaborating on another approach to arrange the data as described: How to show detail data to across then down?
If it is an emergency or you need any further help, please use our support ticketing system, where your questions will be answered in a timely manner according to your support subscription plan.
Regards,
Stef
Telerik
Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.
0
Per
Top achievements
Rank 1
answered on 28 Oct 2013, 09:21 AM
Hi,
I failed to open your test project using both VS 2010 and 2012 (see attached screen dumps).
For VS2010 I don't have any solution open prior to opening your project, the error msg for 2012 I don't have a clue why.
Do you mean I should set the textbox values manually to e.g. Fields.c1, Fields.c2 ...?
When I do I get runtime errors from the report saying there's no field named c1, c2 etc.
BR,
Per
I failed to open your test project using both VS 2010 and 2012 (see attached screen dumps).
For VS2010 I don't have any solution open prior to opening your project, the error msg for 2012 I don't have a clue why.
Do you mean I should set the textbox values manually to e.g. Fields.c1, Fields.c2 ...?
When I do I get runtime errors from the report saying there's no field named c1, c2 etc.
BR,
Per
0
Hello Per,
Try to get just the report definition from the attachment and place it in your own project having references to Telerik Reporting. The changes are that we have named the columns in the DataTable object in your example:
The Table item structure is illustrated in the Table.png screenshot.
We will appreciate it if you elaborate on the scenario, the data structure and content and the layout you want to achieve. Notice that using events to modify the report definition and used data are not recommended and there are other means as expressions to achieve the same.
Regards,
Stef
Telerik
Try to get just the report definition from the attachment and place it in your own project having references to Telerik Reporting. The changes are that we have named the columns in the DataTable object in your example:
private
void
table1_NeedDataSource(
object
sender, EventArgs e)
{
DataTable dt =
new
DataTable();
DataColumn c1 =
new
DataColumn() { ColumnName =
"c1"
};
DataColumn c2 =
new
DataColumn() { ColumnName =
"c2"
};
DataColumn c3 =
new
DataColumn() { ColumnName =
"c3"
};
DataColumn c4 =
new
DataColumn() { ColumnName =
"c4"
};
DataColumn c5 =
new
DataColumn() { ColumnName =
"c5"
};
DataRow r;
dt.Columns.Add(c1);
dt.Columns.Add(c2);
dt.Columns.Add(c3);
dt.Columns.Add(c4);
dt.Columns.Add(c5);
for
(
int
i = 0; i < 14; i++)
//projdef
{
r = dt.NewRow();
for
(
int
j = 0; j < 5; j++)
{
if
(i >= 14)
break
;
r[j] = i.ToString() +
"string"
;
// _projectsAffected[i];
i++;
}
i -= 1;
dt.Rows.Add(r);
}
(sender
as
Telerik.Reporting.Processing.Table).DataSource = dt;
}
The Table item structure is illustrated in the Table.png screenshot.
We will appreciate it if you elaborate on the scenario, the data structure and content and the layout you want to achieve. Notice that using events to modify the report definition and used data are not recommended and there are other means as expressions to achieve the same.
Regards,
Stef
Telerik
Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.