This is a migrated thread and some comments may be shown as answers.

dynamic report with many tables

1 Answer 222 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Y
Top achievements
Rank 1
Y asked on 22 Oct 2012, 02:02 PM

I am trying to build a dynamic report with many tables which have different columns definition.

My source is a list of data table

My code is:

public EntregaReport()
       {
 
 
           InitializeComponent();
           var list = Entrega.GetEntregaDocumentos("BERK_122");
           HtmlTextBox textboxHeader;
           HtmlTextBox textBox;
           foreach (DataTable dataTable in list)
           {
               Table table = new Table();
                
 
               //SetTableProperties(ref table);
 
               detail.Items.Add(table);
               table.ColumnHeadersPrintOnEveryPage = true;
               table.DataSource = dataTable;
              
 
               Telerik.Reporting.HtmlTextBox textboxGroup;
               Telerik.Reporting.HtmlTextBox textBoxTable;
               table.ColumnGroups.Clear();
               table.Body.Columns.Clear();
               table.Body.Rows.Clear();
               int colCount = dataTable.Columns.Count;
               for (int i = 0; i <= colCount - 1; i++)
               {
                   Telerik.Reporting.TableGroup tableGroupColumn = new Telerik.Reporting.TableGroup();
                   table.ColumnGroups.Add(tableGroupColumn);
                   table.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 = dataTable.Columns[i].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." + dataTable.Columns[i].ColumnName;
                   textBoxTable.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
                   table.Body.SetCellContent(0, i, textBoxTable);
                   table.Items.AddRange(new ReportItemBase[] { textBoxTable, textboxGroup });
 
               }
               
 
           }
       }


It´s seems the tables are created but the data is not bind, do I miss something.

Thanks Jochanan

1 Answer, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 25 Oct 2012, 01:12 PM
Hi Jochanan,

You don't seem to set Body Rows or RowGroups anywhere. The Table item needs both rows and columns (and their corresponding groups) to function properly. For an example of dynamically generated table you can check the following forum thread: Dynamic Table Columns.

All the best,
Elian
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Y
Top achievements
Rank 1
Answers by
Elian
Telerik team
Share this question
or