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

Display Hierarchical Data with Table in report

2 Answers 225 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 03 Dec 2010, 04:54 PM
I have a report that has some chart and tables inside.
Chart is working properly. For Table i have created nested classes and i have assigned a those classes to related table.

Description:
I have MainTable which shows the list of CareAreas.
Inside Main Table i have another table called Detaildetable1 which shows the list of Questions.and Inside the DetailTable1
There is one more table DetailTable2, which shows the Resident's Information.

I have created 3 classes.
public class CareAreaDetail
    {
        private String _care;
        private QCIDetail[] _qci;
        public String CareAreaQCITag
        {
            get
            {
                return _care;
            }
            set
            {
                _care = value;
            }
        }
        public QCIDetail[] qci
        {
            get
            {
                return _qci;
            }
            set
            {
                _qci = value;
            }
        }
    }
    public class QCIDetail
    {
        private String _qcisn;
        private ResidentDetail[] _resindet;
        public String QuestionShortName
        {
            get { return _qcisn; }
            set { _qcisn = value; }
        }

        public ResidentDetail[] resDetail
        {
            get
            {
                return _resindet;
            }
            set
            {
                _resindet = value;
            }
        }
    }
    public class ResidentDetail
    {
        private String _resident, _room;
        private DateTime _adate;
        //public String QuestionShortName { get;set;}
        public String ResidentName
        {
            get
            {
                return _resident;
            }
            set
            {
                _resident = value;
            }
        }
        public String Room
        {
            get
            {
                return _room;
            }
            set
            {
                _room = value;
            }
        }
        public DateTime AssessmentDate
        {
            get
            {
                return _adate;
            }
            set
            {
                _adate = value;
            }
        }
    }

Now on Main Table's NeedDataSource event i have assigned the Array Object of CareAreaDetail Class.
For DetailedTable1's needdatasource property i have assigned QCIDetailed Class object and for DetailTable2, ResidentDetail  class object.

Now where report is generated it shows proper Data in MainTable. bt in DetailTable1 and DetailTable2 it shows the same data for all the rows. i.e. for DetailTable1 it shows the data at index 0 in the QCITable class array in all rows and
for DetailTable2 it shows the data at index 0 in the ResidentDetail class array.

Here is the code.

private void DetailTable2_NeedDataSource_1(object sender, EventArgs e)
        {
            Processing.Table table = (Processing.Table)sender;
            DetailTable2.DataSource = table.DataObject["resDetail"];
        }

        private void DetailTable1_NeedDataSource_1(object sender, EventArgs e)
        {
            Processing.Table table = (Processing.Table)sender;
            DetailTable1.DataSource = table.DataObject["qci"];
        }

        private void MainTable_NeedDataSource_1(object sender, EventArgs e)
        {
            DataTable dt = GetAllResponses();
            DataTable DistinctCareAreaTable = SelectDistinct(dt, "CareArea");
            CareAreaDetail[] cad = new CareAreaDetail[DistinctCareAreaTable.Rows.Count];
            int i = 0;
            foreach (DataRow row in DistinctCareAreaTable.Rows)
            {
                cad[i] = new CareAreaDetail();
                cad[i].CareAreaQCITag = "Care Area: " + row[0].ToString().Trim() + " (" + dt.Select("CareArea='" + row[0].ToString().Trim() + "'")[0]["QuestionTag"].ToString() + ")";
                DataTable dtTemp = dt.Copy();
                dtTemp.Clear();
                DataRow[] TempDataRow = dt.Select("CareArea='" + row[0].ToString() + "'");
                foreach (DataRow dr in TempDataRow)
                    dtTemp.LoadDataRow(dr.ItemArray, false);
                DataTable DistinctQCITable = SelectDistinct(dtTemp, "QuestionShortName");
                QCIDetail[] qd = new QCIDetail[DistinctQCITable.Rows.Count];
                int j = 0;
                foreach (DataRow drQCI in DistinctQCITable.Rows)
                {
                    qd[j] = new QCIDetail();
                    qd[j].QuestionShortName = drQCI[0].ToString();

                    DataRow[] ResidentDataRow = dt.Select("QuestionShortName='" + drQCI[0].ToString() + "'");
                    ResidentDetail[] resDetail = new ResidentDetail[ResidentDataRow.Length];
                    int k = 0;
                    foreach (DataRow drRes in ResidentDataRow)
                    {
                        resDetail[k] = new ResidentDetail();
                        resDetail[k].ResidentName = drRes["Resident"].ToString();
                        resDetail[k].Room = drRes["Room"].ToString();
                        resDetail[k].AssessmentDate = (DateTime)drRes["AssessmentDate"];
                        k++;
                    }

                    qd[j].resDetail = resDetail;
                    j++;
                }
                cad[i].qci = qd;
                i++;
            }

            Processing.Table table = (Processing.Table)sender;
            table.DataSource = cad; // DATA assigned in the datasource is accurate and in proper format.
        }
I have attached Image of that report.

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 06 Dec 2010, 10:23 AM
Hello Jay,

First note that when you're in the context of NeedDataSource event, you should use the processing object and not the definition. More info is available in the Using the NeedDataSource event to connect data help article.
Additionally there was similar problem that slipped into the Q3 release, that we addressed immediately in an internal build available for download in your account, so please upgrade.

Kind regards,
Steve
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
Jay
Top achievements
Rank 1
answered on 21 Dec 2010, 09:55 PM
I have upgraded my telerik version with internal builds Version=4.2.10.1130. But i am facing the same problem.
Tags
General Discussions
Asked by
Jay
Top achievements
Rank 1
Answers by
Steve
Telerik team
Jay
Top achievements
Rank 1
Share this question
or