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

Incorrect dynamic table columns

5 Answers 217 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tobania
Top achievements
Rank 1
Tobania asked on 12 Mar 2013, 12:28 PM
Hey,

We have upgraded the telerik reporting to Q1 2013 and since this update a table with dynamic columns has the wrong data. 

These columns are added programmaticly and when debuggen the columns are added to the tblOccupancy. When the view is rendered the table has the correct headers but all columns contain the value of the first column and not the value it should show. Before the upgrade this worked.

The attached image shows the result. The value marked in yellow should be a1, a2, ...

for (DateTime date = startDate.AddDays(-1); date <= endDate ; date = date.AddDays(1))
            {
                TableGroup tableGroupColumn = new TableGroup();
                tblOccupancy.ColumnGroups.Add(tableGroupColumn);
 
                tblOccupancy.Body.Columns.Add(new TableBodyColumn(Unit.Inch(0.01)));
 
                Telerik.Reporting.TextBox textBoxGroup = new Telerik.Reporting.TextBox();
                if (i == 1)
                {
                    textBoxGroup.Value = "Medewerker";
                    textBoxGroup.Size = new SizeU(Unit.Inch(2), Unit.Inch(0.3));
                }
                else
                {
                    textBoxGroup.Value = date.ToString("ddd dd-MM");
                    textBoxGroup.Size = new SizeU(Unit.Inch(0.7), Unit.Inch(0.3));                   
                }
 
                textBoxGroup.Style.BackgroundColor = Color.FromArgb(220, 231, 245);
                textBoxGroup.Style.Font.Bold = true;
                textBoxGroup.Style.VerticalAlign = VerticalAlign.Middle;
                textBoxGroup.Style.BorderColor.Default = Color.FromArgb(27, 149, 203);
                textBoxGroup.Style.BorderStyle.Default = BorderType.Solid;
                tableGroupColumn.ReportItem = textBoxGroup;
 
                Telerik.Reporting.TextBox textBoxTable = new Telerik.Reporting.TextBox();               
                if (i == 1)
                {
                    textBoxTable.Value = "=Fields.EmployeeName";
                }
                else
                {
                    textBoxTable.ItemDataBinding += new EventHandler(textBoxTable_ItemDataBinding);
                    if (date.DayOfWeek == DayOfWeek.Saturday || date.DayOfWeek == DayOfWeek.Sunday)
                    {
                        textBoxTable.Style.BackgroundColor = Color.FromArgb(255, 194, 194, 194);
                    }
                    textBoxTable.Name = i - 1 + "";
                    textBoxTable.Value = "a" + i;// "=Anton.Server.Reports.ReportGenerator.GetValueFromDictionaryById(Fields.ValueForDay," + (i - 1) + ")";
                }
 
                textBoxTable.Style.BorderColor.Default = Color.FromArgb(27, 149, 203);
                textBoxTable.Style.BorderStyle.Default = BorderType.Solid;
                textBoxTable.Style.BorderWidth.Default = new Unit(0.5, UnitType.Point);
                textBoxTable.Style.VerticalAlign = VerticalAlign.Middle;
                textBoxTable.Size = new SizeU(Unit.Inch(0.01), Unit.Inch(0.2));
                 
                tblOccupancy.Body.SetCellContent(0, i - 1, textBoxTable);
                tblOccupancy.Items.AddRange(new ReportItemBase[] { textBoxTable, textBoxGroup });
 
                i++;
            }

Sodi we

5 Answers, 1 is accepted

Sort by
0
Hadib Ahmabi
Top achievements
Rank 1
answered on 14 Mar 2013, 09:02 AM
Check your table's definition after you have created it and more precisely the expression in the body cells. I believe that for some reason they might be the same. 
Additionally since you are creating the table programmatically why do you need the ItemDataBinding event of the cells?
Also try to comment it and see if the issue isn't there. 
0
Tobania
Top achievements
Rank 1
answered on 14 Mar 2013, 11:02 AM
We do need the the ItemDataBinding and this event was called before. But this event isn't causing the problem because it should work without the event (I commented the add event to be sure). 

I checked the body cells values but these are all having the correct values when debugging.
0
Elian
Telerik team
answered on 18 Mar 2013, 03:17 PM
Hello Sodi we,

It will be best if you open a support ticket and attach a runnable sample that exposes the problem, so we can test it locally. Basically there is no reason that dynamic tables should stop working after upgrade, especially when the table is correctly built and the expression are right. 
 
All the best,
Elian
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.

0
Tobania
Top achievements
Rank 1
answered on 19 Mar 2013, 08:05 AM
Ok I created a ticket. 

Ticket Id = 672332

Sodi We
0
Accepted
Elian
Telerik team
answered on 19 Mar 2013, 01:17 PM
Hello Sodi We,

Basically the ItemDataBinding event is a bit too late to change the item's definition and you can get unexpected behaviour (as in your case). In this particular case you can fix the issue by manually giving names to the column groups. 
TableGroup tableGroupColumn = new TableGroup();
//add this
tableGroupColumn.Name = i.ToString();
However, there is no guarantee that another problem won't surface at some point. Our suggestion is to avoid changing the report items definitions when the processing has already started. 
Regards,
Elian
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.

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