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

data is being duplicated - dynamic report

2 Answers 90 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Elvis
Top achievements
Rank 1
Elvis asked on 16 Jul 2013, 05:37 PM
Hi Telerik,
I have an issue in regards to dynamic reports.
I am adding columns dynamically, but cell is being duplicated for all cells in content section, for each row.
This is my code:
private void table1_ItemDataBinding(object sender, EventArgs e)
        {

           // table is being populated from as WS

            processingTable.DataSource = table;


            //we do not clear the Rows collection, since we have a details row group and need to create columns only
            this.table1.ColumnGroups.Clear();
            this.table1.Body.Columns.Clear();
            this.table1.Body.Rows.Clear();
            int i = 0;
            this.table1.ColumnHeadersPrintOnEveryPage = true;

            // Properties are the object properties - they will represent the columns
            foreach (PropertyInfo property in properties)
            {
                Telerik.Reporting.HtmlTextBox textboxGroup = null;
                Telerik.Reporting.HtmlTextBox textBoxTable = null;

                Telerik.Reporting.TableGroup tableGroupColumn = new Telerik.Reporting.TableGroup();
                this.table1.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 = property.Name;
                textboxGroup.Size = new SizeU(Unit.Inch(1.1+i), 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." + property.Name;
                textBoxTable.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
                this.table1.Body.SetCellContent(0, i++, textBoxTable,1,1);
                this.table1.Items.AddRange(new ReportItemBase[] { textboxGroup, textBoxTable });
                
                this.table1.ColumnGroups.Add(tableGroupColumn);
                
            }

        }
I am attaching the screenshot for it. Basically all contain the same value for all columns, it´s taking the first value I set in
this.table1.Body.SetCellContent(0, i++, textBoxTable,1,1);
but all fields are different for each column.
I am attaching an image with some sample data for one row (fields.png).
Please help.

Thanks,

2 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 18 Jul 2013, 04:58 PM
I am experiencing the exact same issue.  We are using Q2 2013 version.  Other projects using Q3 2012 are working fine with the exact same code.
0
Unknown
Top achievements
Rank 1
answered on 19 Jul 2013, 02:23 PM
Try debugging your application to see if the correct values are assigned. Also you can try setting the cell content outside the loop, with creating a single textbox for each field. Try making the example as simple as possible - this will give you the option to understand faster where the issue is.
Tags
General Discussions
Asked by
Elvis
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Unknown
Top achievements
Rank 1
Share this question
or