Incorrect dynamic table columns

6 posts, 1 answers
  1. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 12 Mar 2013 Link to this post

    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
  2. Hadib Ahmabi
    Hadib Ahmabi avatar
    181 posts
    Member since:
    Nov 2011

    Posted 14 Mar 2013 Link to this post

    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. 
  3. DevCraft banner
  4. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 14 Mar 2013 Link to this post

    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.
  5. Elian
    Admin
    Elian avatar
    435 posts

    Posted 18 Mar 2013 Link to this post

    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.

  6. Sodi We
    Sodi We avatar
    160 posts
    Member since:
    Apr 2010

    Posted 19 Mar 2013 Link to this post

    Ok I created a ticket. 

    Ticket Id = 672332

    Sodi We
  7. Answer
    Elian
    Admin
    Elian avatar
    435 posts

    Posted 19 Mar 2013 Link to this post

    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.

Back to Top
DevCraft banner