Telerik Forums
Reporting Forum
1 answer
147 views
Hi
--------------------------
EDIT:
I am really sorry for the long post, tell me if you want it to a pastebin, the problem here after some debugging is that the structure seems ok after going through properties when opening it in debugging mode, the really big problem for me is that I canot get any kind of output from the report telling me what is wrong and why it's thinking there is no report. like some kind of exception catching
--------------------------
I am using the Q2 2010 SP1 4.1 and telerik radcontrols for winforms Q1 2012 SP1 and I just created a report by using some dynamic coding in the report(which is embeded in a winform), at first I copy pasted and edited a lot from some code made in designtime, however as this resulted in ugly (but working) code I created a class to do it for me however it now shows no report, just a message saying "Object reference not set to an instance of an object."

this is my weekreport.cs class containing the definition class for the report, the uglypopulate method is the one which works, the almostpopulatelikeabaws is the new code I created with the help class

using System.Collections.Generic;
using System.Data;
using BE;
 
namespace TimeRegisterClient
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;
 
    /// <summary>
    /// Summary description for WeekReport.
    /// </summary>
    public partial class TidsRapport : Telerik.Reporting.Report
    {
        private void setEmptyRowStandard(Telerik.Reporting.TextBox RowBox)
        {
            RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Value = "";
        }
        private void setTotalRowStandard(Telerik.Reporting.TextBox RowBox)
        {
            RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.BorderWidth.Top = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.BorderStyle.Top = BorderType.Solid;
            RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.TextAlign = HorizontalAlign.Left;
            RowBox.Style.VerticalAlign = VerticalAlign.Middle;
        }
 
        private void setCustomerRowStandard(Telerik.Reporting.TextBox RowBox)
        {
            RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.TextAlign = HorizontalAlign.Left;
            RowBox.Style.VerticalAlign = VerticalAlign.Middle;
        }
        private void setDayHeaderStandard(Telerik.Reporting.TextBox RowBox)
        {
            RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.BorderWidth.Bottom = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point); ;
            RowBox.Style.BorderStyle.Bottom = BorderType.Solid;
            RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.VerticalAlign = VerticalAlign.Middle;
        }
        private void setColumnStandard(Telerik.Reporting.TextBox RowBox,Unit height)
        {
            RowBox.Style.Font.Underline = true;
            RowBox.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(14D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
            RowBox.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
            RowBox.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm),height);
        }
        public TidsRapport(Dictionary<DayOfWeek, Dictionary<int, UpdCus>> values, UserDetail user, DateTime from, DateTime to)
            : this()
        {
            FromTime = from;
            ToTime = to;
            WriteDate();
            TxtFraBruger.Value += user.Name;
             
            populatealmostlikeabaws(values);
           //uglypopulate(values);
            
            
             
 
        }
        #region new
        private void populatealmostlikeabaws(Dictionary<DayOfWeek, Dictionary<int, UpdCus>> values)
        {
            PointU l =
                new PointU(
                    new Unit(0.299999862909317D, UnitType.Cm),
                    new Unit(4.5999999046325684D, UnitType.Cm));
            SizeU s = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(12.600000381469727D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(2.4000000953674316D, Telerik.Reporting.Drawing.UnitType.Cm));
            ReportTableGenerator tg = new ReportTableGenerator(s, l, new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm));
 
            setColumnStandard(tg.Nextbox, tg.DefaultRowHeight);
            tg.Nextbox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left;
            tg.Nextbox.Value = "Dag/Kunde";
            tg.addColumn(new Telerik.Reporting.Drawing.Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm));
 
            setColumnStandard(tg.Nextbox, tg.DefaultRowHeight);
            tg.Nextbox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center;
            tg.Nextbox.Value = "Tider";
            tg.addColumn(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm));
 
            tg.DefaultRowHeight = new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm);
            Dictionary<int, UpdCus> total = new Dictionary<int, UpdCus>();
            DayOfWeek DayOfWork = FromTime.DayOfWeek;
 
            for (int i = 0; i < (values.Keys.Count + 1); i++)
            {
                Boolean notlast = i < values.Keys.Count;
 
                setDayHeaderStandard(tg.Nextbox);
                tg.Nextbox.Style.TextAlign = HorizontalAlign.Left;
                tg.Nextbox.Style.Padding.Left = new Unit(1.5, UnitType.Cm);
                tg.Nextbox.Style.Font.Bold = true;
 
                if (notlast)
                    tg.Nextbox.Value = DayOfWork.ToString();
                else
                    tg.Nextbox.Value = "Samlet tid";
 
                tg.addRowCell();
 
                setDayHeaderStandard(tg.Nextbox);
                tg.Nextbox.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center;
                tg.addRowCell();
 
                tg.appendRow();
 
                Decimal weekHours = 0;
                #region Customer Times loop
 
                Dictionary<int, UpdCus> temp;
                if (notlast)
                    temp = values[DayOfWork];
                else
                    temp = total;
                foreach (UpdCus c in temp.Values)
                {
                    if (notlast)
                    {
                        if (!total.ContainsKey(c.CustomerId))
                        {
                            total.Add(c.CustomerId, c);
                        }
                        else
                        {
                            total[c.CustomerId].update.TimeSpent += c.update.TimeSpent;
                        }
                    }
 
 
 
                    setCustomerRowStandard(tg.Nextbox);
                    tg.Nextbox.Style.Padding.Left = new Unit(2.5, UnitType.Cm);
                    tg.Nextbox.Value = c.CustomerName;
 
                    tg.addRowCell();
                    setCustomerRowStandard(tg.Nextbox);
                    tg.Nextbox.Value = c.update.TimeSpent.ToString();
 
                    tg.addRowCell();
                    tg.appendRow();
 
                    weekHours += c.update.TimeSpent;
                }
                #endregion
                #region Total Row add
 
 
                setTotalRowStandard(tg.Nextbox);
 
                tg.Nextbox.Style.Padding.Left = new Unit(2.5, UnitType.Cm);
                tg.Nextbox.Value = "total tid registreret " + (notlast ? DayOfWork + "" : "I alt");
                tg.addRowCell();
                setTotalRowStandard(tg.Nextbox);
                tg.Nextbox.Value = weekHours + "";
                tg.addRowCell();
                tg.appendRow();
                #endregion
 
                #region empty row add
                if (notlast)
                {
                    setEmptyRowStandard(tg.Nextbox);
                    tg.addRowCell();
                    setEmptyRowStandard(tg.Nextbox);
                    tg.addRowCell();
                    tg.appendRow();
 
 
                }
                #endregion
 
                DayOfWork++;
            }
            tg.finishTable();
            DetailSection.Items.Add(tg.table);
        }
        #endregion
 
        #region old
        private void uglypopulate(Dictionary<DayOfWeek, Dictionary<int, UpdCus>> values)
        {
 
            Telerik.Reporting.Table DataTable;
            List<Telerik.Reporting.ReportItemBase> tableItems = new List<ReportItemBase>();
            Telerik.Reporting.TextBox FirstDay = new Telerik.Reporting.TextBox();
            Telerik.Reporting.TextBox empty = new Telerik.Reporting.TextBox();
            DataTable = new Telerik.Reporting.Table();
            DetailSection.Items.Add(DataTable);
            Telerik.Reporting.TextBox TextHeader;
            Telerik.Reporting.TextBox HourHeader;
            Telerik.Reporting.TableGroup tableGroup1 = new Telerik.Reporting.TableGroup();
            Telerik.Reporting.TableGroup tableGroup2 = new Telerik.Reporting.TableGroup();
            Telerik.Reporting.TableGroup tableGroup3 = new Telerik.Reporting.TableGroup();
 
 
            TextHeader = new Telerik.Reporting.TextBox();
            HourHeader = new Telerik.Reporting.TextBox();
 
            TextHeader = new Telerik.Reporting.TextBox();
            HourHeader = new Telerik.Reporting.TextBox();
            DataTable.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(new Telerik.Reporting.Drawing.Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm)));
            DataTable.Body.Columns.Add(new Telerik.Reporting.TableBodyColumn(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm)));
            DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm)));
            DataTable.Body.SetCellContent(0, 0, FirstDay);
            DataTable.Body.SetCellContent(0, 1, empty);
            tableGroup1.ReportItem = TextHeader;
            tableGroup2.ReportItem = HourHeader;
            DataTable.ColumnGroups.Add(tableGroup1);
            DataTable.ColumnGroups.Add(tableGroup2);
            tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] {
            FirstDay,
            empty,
            TextHeader,
            HourHeader});
            DataTable.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(0.299999862909317D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(4.5999999046325684D, Telerik.Reporting.Drawing.UnitType.Cm));
            DataTable.Name = "DataTable";
 
            DataTable.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(12.600000381469727D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(2.4000000953674316D, Telerik.Reporting.Drawing.UnitType.Cm));
 
 
            TextHeader.Name = "TextHeader";
            TextHeader.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm));
            TextHeader.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
 
 
            TextHeader.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(14D, Telerik.Reporting.Drawing.UnitType.Point);
            TextHeader.Style.Font.Underline = true;
            TextHeader.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left;
            TextHeader.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
            TextHeader.Value = "Dag/Kunde";
 
            HourHeader.Name = "HourHeader";
            HourHeader.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm));
            HourHeader.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
 
            HourHeader.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(14D, Telerik.Reporting.Drawing.UnitType.Point);
            HourHeader.Style.Font.Underline = true;
            HourHeader.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center;
            HourHeader.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
            HourHeader.Value = "Tider";
            Boolean made = true;
            int row = 1;
            Dictionary<int, UpdCus> total = new Dictionary<int, UpdCus>();
            DayOfWeek DayOfWork = FromTime.DayOfWeek;
            for (int i = 0; i < (values.Keys.Count + 1); i++)
            {
                Boolean notlast = i < values.Keys.Count;
                if (made)
                {
                    made = false;
                }
                else
                {
                    DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm)));
                    FirstDay = new Telerik.Reporting.TextBox();
                    empty = new Telerik.Reporting.TextBox();
                    DataTable.Body.SetCellContent(row, 0, FirstDay);
                    DataTable.Body.SetCellContent(row, 1, empty);
                    row++;
                    tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] {
            FirstDay,
            empty});
 
                }
                TableGroup t = new TableGroup();
                tableGroup3.ChildGroups.Add(t);
                FirstDay.Name = DayOfWork.ToString();
                //FirstDay.Size = new SizeU(new Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm));
                FirstDay.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
                FirstDay.Style.BorderWidth.Bottom = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point); ;
                FirstDay.Style.BorderStyle.Bottom = BorderType.Solid;
                FirstDay.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
                FirstDay.Style.TextAlign = HorizontalAlign.Left;
                FirstDay.Style.VerticalAlign = VerticalAlign.Middle;
                FirstDay.Style.Padding.Left = new Unit(1.5, UnitType.Cm);
 
                FirstDay.Style.Font.Bold = true;
                if (notlast)
                    FirstDay.Value = DayOfWork.ToString();
                else
                    FirstDay.Value = "Samlet tid";
 
 
 
 
                // empty.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm));
                empty.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Center;
                empty.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
                empty.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
                empty.Style.BorderWidth.Bottom = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point);
                empty.Style.BorderStyle.Bottom = BorderType.Solid;
                empty.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
                Decimal weekHours = 0;
                #region Customer Times loop
 
                Dictionary<int, UpdCus> temp;
                if (notlast)
                    temp = values[DayOfWork];
                else
                    temp = total;
                foreach (UpdCus c in temp.Values)
                {
                    if (notlast)
                    {
                        if (!total.ContainsKey(c.CustomerId))
                        {
                            total.Add(c.CustomerId, c);
                        }
                        else
                        {
                            total[c.CustomerId].update.TimeSpent += c.update.TimeSpent;
                        }
                    }
                    DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)));
                    Telerik.Reporting.TextBox Customer = new Telerik.Reporting.TextBox();
                    Telerik.Reporting.TextBox Time = new Telerik.Reporting.TextBox();
                    empty.Name = DayOfWork.ToString() + "e";
                    DataTable.Body.SetCellContent(row, 0, Customer);
                    DataTable.Body.SetCellContent(row, 1, Time);
                    row++;
                    tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] {
            Customer,
            Time});
                    TableGroup t1 = new TableGroup();
                    tableGroup3.ChildGroups.Add(t1);
                    Customer.Name = DayOfWork.ToString() + c.CustomerName;
                    // Customer.Size = new SizeU(new Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm));
                    Customer.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
                    Customer.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
                    Customer.Style.Padding.Left = new Unit(2.5, UnitType.Cm);
                    Customer.Style.TextAlign = HorizontalAlign.Left;
                    Customer.Style.VerticalAlign = VerticalAlign.Middle;
                    Customer.Value = c.CustomerName;
                    //Console.WriteLine(c.CustomerName + ": " + c.update.TimeSpent);
                    //TableGroup n = new TableGroup();
                    // n.Grouping.Add(c.CustomerName);
                    // DataTable.RowGroups.Add(n);
                    Time.Name = DayOfWork.ToString() + "T";
                    Time.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
                    //Time.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm));
                    Time.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left;
                    Time.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
                    Time.Value = c.update.TimeSpent.ToString();
                    weekHours += c.update.TimeSpent;
                }
                #endregion
                #region Total Row add
 
                DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)));
                Telerik.Reporting.TextBox CustomerTotal = new Telerik.Reporting.TextBox();
                Telerik.Reporting.TextBox TimeTotal = new Telerik.Reporting.TextBox(); empty.Name = DayOfWork.ToString() + "e";
                DataTable.Body.SetCellContent(row, 0, CustomerTotal);
                DataTable.Body.SetCellContent(row, 1, TimeTotal);
                row++;
                tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] {
            CustomerTotal,
            TimeTotal});
                TableGroup t2 = new TableGroup();
                tableGroup3.ChildGroups.Add(t2);
                CustomerTotal.Name = DayOfWork.ToString() + "TotalDescription" + notlast;
                //CustomerTotal.Size = new SizeU(new Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm));
                CustomerTotal.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
                CustomerTotal.Style.BorderWidth.Top = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point);
                CustomerTotal.Style.BorderStyle.Top = BorderType.Solid;
 
                CustomerTotal.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
                CustomerTotal.Style.Padding.Left = new Unit(2.5, UnitType.Cm);
                CustomerTotal.Style.TextAlign = HorizontalAlign.Left;
                CustomerTotal.Style.VerticalAlign = VerticalAlign.Middle;
                CustomerTotal.Value = "total tid registreret " + (notlast ? DayOfWork + "" : "I alt");
 
                TimeTotal.Name = DayOfWork.ToString() + "TotalTimeTotal" + notlast;
                //TimeTotal.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm));
                TimeTotal.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left;
                TimeTotal.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Middle;
                TimeTotal.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
                TimeTotal.Style.BorderWidth.Top = new Telerik.Reporting.Drawing.Unit(1D, Telerik.Reporting.Drawing.UnitType.Point);
                TimeTotal.Style.BorderStyle.Top = BorderType.Solid;
                TimeTotal.Value = weekHours + "";
                #endregion
 
                #region empty row add
                if (notlast)
                {
                    DataTable.Body.Rows.Add(new Telerik.Reporting.TableBodyRow(new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm)));
                    Telerik.Reporting.TextBox CustomerEmpty = new Telerik.Reporting.TextBox();
                    Telerik.Reporting.TextBox TimeEmpty = new Telerik.Reporting.TextBox(); empty.Name = DayOfWork.ToString() + "e";
                    DataTable.Body.SetCellContent(row, 0, CustomerEmpty);
                    DataTable.Body.SetCellContent(row, 1, TimeEmpty);
                    row++;
                    tableItems.AddRange(new Telerik.Reporting.ReportItemBase[] {
            CustomerEmpty,
            TimeEmpty});
                    TableGroup t3 = new TableGroup();
                    tableGroup3.ChildGroups.Add(t3);
                    CustomerEmpty.Name = DayOfWork.ToString() + "dEmpty";
                    // CustomerEmpty.Size = new SizeU(new Unit(10.09999942779541D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm));
                    CustomerEmpty.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
 
                    CustomerEmpty.Style.Font.Size = new Telerik.Reporting.Drawing.Unit(12D, Telerik.Reporting.Drawing.UnitType.Point);
                    CustomerEmpty.Style.Padding.Left = new Unit(2.5, UnitType.Cm);
                    CustomerEmpty.Style.TextAlign = HorizontalAlign.Left;
                    CustomerEmpty.Style.VerticalAlign = VerticalAlign.Bottom;
                    CustomerEmpty.Value = "";
 
                    TimeEmpty.Name = DayOfWork.ToString() + "EmptyTime";
                    //TimeEmpty.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(2.4999997615814209D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(0.5D, Telerik.Reporting.Drawing.UnitType.Cm));
                    TimeEmpty.Style.TextAlign = Telerik.Reporting.Drawing.HorizontalAlign.Left;
                    TimeEmpty.Style.VerticalAlign = Telerik.Reporting.Drawing.VerticalAlign.Bottom;
                    TimeEmpty.Style.BorderWidth.Default = new Telerik.Reporting.Drawing.Unit(0D, Telerik.Reporting.Drawing.UnitType.Point);
 
                    TimeEmpty.Value = "";
                }
                #endregion
 
                DayOfWork++;
            }
            DataTable.Items.AddRange(tableItems.ToArray());
 
            DataTable.RowGroups.Add(tableGroup3);
            tableGroup3.Grouping.AddRange(new Telerik.Reporting.Data.Grouping[] {
            new Telerik.Reporting.Data.Grouping("")});
            tableGroup3.Name = "DetailGroup";
        }
 
            #endregion
 
        public TidsRapport()
        {
            InitializeComponent();
 
        }
 
        private void WriteDate()
        {
 
 
            TitleTextBox.Value += FromTime.ToShortDateString() + " til " + ToTime;
 
            TitleTextBox.Width += TitleTextBox.Width + new Unit(8.0, UnitType.Cm);
 
        }
 
        protected DateTime FromTime { get; set; }
 
        protected DateTime ToTime { get; set; }
    }
 
}

And this is the helper class

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using Telerik.Reporting;
using Telerik.Reporting.Data;
using Telerik.Reporting.Drawing;
 
namespace TimeRegisterClient
{
    class ReportTableGenerator
    {
        public int CurrentRow { get; private set; }
        public int CurrentColumn { get; private set; }
        public int MaxColumns { get; private set; }
         
        public TextBox Nextbox { get; set; }
        private List<TextBox> nextRow { get; set; }
        private Table GeneratedTable;
        public Table table
        {
            get
            {
                if (isFinished)
                    return GeneratedTable;
                return null;
            }
            private set { GeneratedTable = value; }
        }
        public Boolean isFinished { get; private set; }
        public Boolean ColumnsSet { get; set; }
        private List<ReportItemBase> tableItems { get; set; }
        public Unit DefaultRowHeight { get; set; }
        public ReportTableGenerator(Unit colHeight)
        {
            ColumnsSet = false;
            CurrentColumn = 0;
            CurrentRow = 0;
            MaxColumns = 0;
            DefaultRowHeight = new TextBox().Size.Height;
            RowGroup = new TableGroup();
            tableItems = new List<ReportItemBase>();
            GeneratedTable = new Table();
            //GeneratedTable.Body.Rows.Add(new TableBodyRow(colHeight));
            resetRow();
            resetBoxes();
            GeneratedTable.Name = "GeneratedTable";
        }
        public ReportTableGenerator( SizeU size,PointU location,Unit columnheight):this(columnheight)
       {
           setDimensions(size,location);
       }
         
        public void finishTable()
        {
            GeneratedTable.Items.AddRange(tableItems.ToArray());
            GeneratedTable.RowGroups.Add(RowGroup);
            RowGroup.Grouping.AddRange(new Grouping[]
                                           {
                                            new Grouping("")
                                           });
            RowGroup.Name = "DetailGroup";
            isFinished = true;
        }
 
        private void resetRow()
        {
            nextRow=new List<TextBox>();
        }
 
         
 
        public void resetBoxes()
        {
            Nextbox = new TextBox();
        }
        
        public void setDimensions(SizeU size, PointU location)
        {
            GeneratedTable.Location = location;
            GeneratedTable.Size = size;
        }
        
        public void addRowCell()
        {
            nextRow.Add(Nextbox);
            resetBoxes();
        }
 
         
 
        public void appendRow()
        {
            int dif = nextRow.Count - (MaxColumns+1);
            if (dif > 0)
                throw new Exception("you added " + dif + " more cells to a row than possible");
            if (!ColumnsSet)
            {
                ColumnsSet = true;
                completeColumns();
            }
            GeneratedTable.Body.Rows.Add(new TableBodyRow(DefaultRowHeight));
            TableGroup newGroup = new TableGroup();
            RowGroup.ChildGroups.Add(newGroup);
            foreach (TextBox t in nextRow)
            {
                if (t.Name.Equals(""))
                    t.Name = CurrentRow + "," + CurrentColumn;
                addCell(t);
            }
            resetRow();
        }
        
        private void addCell(TextBox t)
        {
            GeneratedTable.Body.SetCellContent(CurrentRow,CurrentColumn,t);
            iterateCell();
            tableItems.Add(t);
        }
 
        public void addColumn(Unit Width)
        {
            if(ColumnsSet)
                throw new Exception("You cannot add anymore columns at the given time");
            GeneratedTable.Body.Columns.Add(new TableBodyColumn(Width));
            TableGroup cgroup = new TableGroup();
            MaxColumns++;
             
            cgroup.ReportItem = Nextbox;
            GeneratedTable.ColumnGroups.Add(cgroup);
            addCell(Nextbox);
            resetBoxes();
        }
 
        
        private void completeColumns()
        {
            MaxColumns--;
            iterateCell();
        }
        private void iterateCell()
        {
            if (CurrentColumn >= MaxColumns)
            {
                CurrentColumn = 0;
                CurrentRow++;
            }
            else
            {
                CurrentColumn++;
            }
        }
 
        private TableGroup RowGroup { get; set; }
 
         
    }
}

I also attached a picture of how the report looks once generated, I removed the names of the customers though hope you don't mind

any help is appreciated :)

Update:
I tried adding this code block just to test if it was the generator class or the code using it that was the problem, and it's the generatorclass. This is the code I used to show one row with and I still got the problem
PointU l =
                  new PointU(
                      new Unit(0.299999862909317D, UnitType.Cm),
                      new Unit(4.5999999046325684D, UnitType.Cm));
            SizeU s = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(12.600000381469727D, Telerik.Reporting.Drawing.UnitType.Cm), new Telerik.Reporting.Drawing.Unit(2.4000000953674316D, Telerik.Reporting.Drawing.UnitType.Cm));
            ReportTableGenerator rg = new ReportTableGenerator(s, l, new Telerik.Reporting.Drawing.Unit(0.6D, Telerik.Reporting.Drawing.UnitType.Cm));
            rg.Nextbox.Value = "ctest1";
            rg.addColumn(new Unit(0.6D, UnitType.Cm));
            rg.Nextbox.Value = "ctest2";
            rg.addColumn(new Unit(0.6D, UnitType.Cm));
            rg.Nextbox.Value = "row1";
            rg.addRowCell();
            rg.Nextbox.Value = "row12";
            rg.appendRow();
            rg.finishTable();
            DetailSection.Items.Add(rg.table);
Anders
Top achievements
Rank 1
 answered on 13 Sep 2012
1 answer
100 views
Hello,

I tried Telerik Reporting Online demo on Ipad, however it seems none of the scroll bar is working on IPAD.
Is it known issue?
Is there any workaround solution for this? thank you
Peter
Telerik team
 answered on 13 Sep 2012
1 answer
115 views
I have a report that consist of multiple reports.  For example.

dim rpt1 s new report1
dim rpt2 as new report2
Dim reportBook as new Telerk.Reporting.ReportBook()
reportBook.Reports.Add(rpt1)
reportBook.Reports.Add(rpt2)

if rtp1 has no detail lines then I want to be able to suppress the entire page so that the first report I added basically just doesn't show.  I wish it was as easy as just not adding the report to the reportbook but I just can't do this being I don't know yet if there are detail lines.

How can I suppress this report so that it don't show and that also the page numbering is correct?

thanks for your help.
Squall
Top achievements
Rank 1
 answered on 13 Sep 2012
1 answer
367 views
Hello,

I'm considering working with Telerik Reporting but I want to make sure that text boxes can overlap images in the report.  For example, i have an image showing dimensions.  I plan on placing text boxes bound to data over the image where the dimensions are shown.  Can Telerik do something like this?

thansk
francis
Chavdar
Telerik team
 answered on 12 Sep 2012
1 answer
224 views
Hi,

I would like to remove Arrow buttons (Left and Right) from Report Viewer Naviagtion tool Bar.
How can I remove those?

Thanks,
Asit
Chavdar
Telerik team
 answered on 12 Sep 2012
2 answers
113 views
Hello,

I have a table pulling data from a stored procedure, but due to the way the database was set up, some of the strings were cut off. I cannot change the structure of the database, so I was wondering if it was possible to add the part of the string cut off in the [=Fields.whatever] part of the cell.

Here's a simplified example of what I mean....

The table was created like this:
CREATE TABLE ThingColor(
id int PRIMARY KEY,
thing varchar(20),
color varchar(5))

And data inserted:
INSERT INTO ThingColor
VALUES (1, 'sky', 'blue'), (2, 'sun', 'yello');

My stored procedure calls 'thing' and 'color', but the "yello" is missing its w. When I get to the Telerik Report table, is there something similar to an if statement function where, if the string = 'yello', then display 'yellow', that I can add to my [=Fields.color] box?
Matthew
Top achievements
Rank 1
 answered on 12 Sep 2012
0 answers
61 views
I have a telerik report service (Telerik.Reporting.Service.ReportService) that is used by silverlight application. I want also use the same service for iPad version of the application.
The way we are going to implement:
Create a proxy service, that will send requests to ReportService. This proxy service will have 2 methods: RenderAndCache, GetPage. I want to get a page with html format and then just return it to iPad client. But the markup that we got from ReportService has a strange links for images.

Example:
<img alt="Chart" src="&amp;StreamID=3nxve03monw" width="718px" height="600px" /></td>

I want to get the following link
[ApplicationRoot]/ReportService.svc/resources/getrenderstream?instanceID=smth&name=3nxve03monw".

I understand that it's possible just to replace it manually. But I'm interested if there is a way of getting such kind of links from the box.

Alex
Top achievements
Rank 1
 asked on 12 Sep 2012
7 answers
210 views
I'm trying to use the Fields() function in the Groupings property of a report.

It will work if I use a field that is at the base of my object graph. For example:-

=Fields("Price")

However if I try to use a field from deeper in the graph, the generated report is blank. For example:-

=Fields("Supplier.Name")

Both of the above fields work fine as bound fields in the report itself.

Specifying the field directly in the Groupings parameter works as expected:-

=Fields.Supplier.Name

The reason I want to use the Fields function is that I am passing a parameter into the report so I can change the grouping from the page from which the report is run.

Can anyone tell me if the Fields() method should work with deep mapped fields? or was this overlooked when deep object support was added in Q2 2007?

Thanks in advance.
Peter
Telerik team
 answered on 12 Sep 2012
1 answer
110 views
Hi..
Can you provide a sample or direction of how to implement error handing on a report - rendered in the SL viewer.
thx again!
Hrisi
Telerik team
 answered on 12 Sep 2012
1 answer
142 views
Currently we are calling a service that generates our reports and then returns the results and we create a PDF with that:

Dim s as new ServiceName.ReportServiceClient
Dim result as ServiceName.RenderingResults
Dim paramaters as New Dictionary(Of String, Object)

s.Open()
result = s.Render("PDF" "report name here",Nothing,paramaters)

Then we just basically write out the result.DocumentBytes to create our PDF.  This works great for one report but the report needs to contain more than one reportBook.  Basically this report is a combination of reports.  How can I get the "result" that returns into a reportbook so that I can call the render again for the next report so I can add that to the reportbook? or is there a better way?
Hrisi
Telerik team
 answered on 12 Sep 2012
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?