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

Table in subReport not binding issue

6 Answers 260 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kris
Top achievements
Rank 1
Kris asked on 09 Jul 2010, 12:37 AM
I am building a report for the following data:
--> FacilitY
--> Assessments
--> Photos

A facility can have multiple assessments and an assessment can have multiple photos. I can get the Facility data and the Assessments data to show up. I can not get the photos to load. I am loading the Photos SubReport during the 'assessmentsTable_Item
DataBound()' event as a subReport in a cell, but it doesn't appear that it is loading. Here's the code:

private void assessmentsTable
_ItemDataBound(
object sender, EventArgs e)
{
    if (m_HasRecords)
    {
        Telerik.Reporting.Processing.Table tab = (Telerik.Reporting.Processing.Table)sender;
 
 
        Telerik.Reporting.Processing.ProcessingElement[] elems = tab.ChildElements.Find("textBox16", true);
 
        for (int i = 0; i < elems.Length; i++)
        {
            DataTable dt_assessments = GetAssessments();
            Telerik.Reporting.Processing.TextBox assessmentID = (Telerik.Reporting.Processing.TextBox)tab.ChildElements.Find("textBox16", true).GetValue(i);
 
            Telerik.Reporting.Processing.SubReport rep1 = (Telerik.Reporting.Processing.SubReport)tab.ChildElements.Find("subReport1", true).GetValue(i);
            //Telerik.Reporting.SubReport rep2 = (Telerik.Reporting.SubReport)tab.ChildElements.Find("subReport2", true).GetValue(i);
 
            DataTable dt_photos = GetPhotos();
 
            LoadPhotos(dt_photos, assessmentID.Value.ToString(), m_Counter++, table2.Height.Value + 10, rep1);


private void LoadPhotos(DataTable dt_photos, string assessmentID, int i, float height, Telerik.Reporting.Processing.SubReport subReport1)
{
    DataView dv = new DataView(dt_photos, "photoSourceID='" + assessmentID.ToString() + "'", "PhotoDateTime", DataViewRowState.CurrentRows);
    subReport1.Report.DataSource = new RMReports.AssessmentPhotos(dv, m_PhotoDirectory, m_EventID.ToString());
    subReport1.Location = new PointU(new Unit(0.5, UnitType.Inch), new Unit(m_CurrentYLocation + height + 1, UnitType.Inch));
    subReport1.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(7.9999217987060547, Telerik.Reporting.Drawing.UnitType.Inch), new Telerik.Reporting.Drawing.Unit(0.900000274181366, Telerik.Reporting.Drawing.UnitType.Inch));
}

public AssessmentPhotos(DataView dt_photos, string photo_directory, string eventid)
{
    /// <summary>
    /// Required for telerik Reporting designer support
    /// </summary>
    InitializeComponent();
 
    //
    // TODO: Add any constructor code after InitializeComponent call
    //
    m_PhotoDirectory = photo_directory;
    m_EventID = eventid;
    LoadPhotos(dt_photos);
}
 
private void LoadPhotos(DataView dt_photos)
{
    table2.DataSource = dt_photos;
}

Any help would be appreciated.

6 Answers, 1 is accepted

Sort by
0
Kris
Top achievements
Rank 1
answered on 10 Jul 2010, 05:07 PM
I have an update to the post. I have switched out the subreport with a "photos" table inside of a cell of the "assessments" table. During the assessments_ItemDataBound event I am getting the photos table and databinding the table. It does show the table but, the table has no data(like it is not binding). The code is below:

private void assessmentTable_ItemDataBound(object sender, EventArgs e)
{
    if (m_HasRecords)
    {
        Telerik.Reporting.Processing.Table tab = (Telerik.Reporting.Processing.Table)sender;
                         
        Telerik.Reporting.Processing.ProcessingElement[] elems = tab.ChildElements.Find("textBox16", true);
 
        for (int i = 0; i < elems.Length; i++)
        {
            DataTable dt_assessments = GetAssessments();
            Telerik.Reporting.Processing.TextBox assessmentID = (Telerik.Reporting.Processing.TextBox)tab.ChildElements.Find("textBox16", true).GetValue(i);
 
            DataTable dt_dynQuestions = new DataTable();
            if (HasDynamicQuestions())
            {
                dt_dynQuestions = GetDynamicQuestions();
                LoadDynamicQuestions(assessmentID.Value.ToString(), dt_dynQuestions, (Telerik.Reporting.Processing.TextBox)tab.ChildElements.Find("textBox23", true).GetValue(i), (Telerik.Reporting.Processing.TextBox)tab.ChildElements.Find("textBox25", true).GetValue(i));
            }
 
            Telerik.Reporting.Processing.Table photostable = (Telerik.Reporting.Processing.Table)tab.ChildElements.Find("photosTable", true).GetValue(i);
            photostable.DataSource = m_PhotoRecords;
 
            assessmentID.Value = "";
        }
 
    }
}


Any help would be appreciated. thanks

0
Massimiliano Bassili
Top achievements
Rank 1
answered on 13 Jul 2010, 02:08 PM
As written in the Telerik docs (http://www.telerik.com/help/reporting/data-items-need-data-source-event.html), you should use the NeedDataSource event when binding data items programmatically. Another thing outlined in the article and worth noting is that you should use the processing table item when in the context of the event.

P.S Generally using nested tables is not a good architectural solution. In fact other reporting vendors such as SSRS and DevX do not allow nesting tables. Binding the report itself and then the table insight it is the way to go in your case. If you have 3 levels of data, you can always use a subreport in between i.e.

MainReport --> FacilitY
      SubReport --> Assessments
           Table --> Photos

Cheers!
0
Kris
Top achievements
Rank 1
answered on 06 Aug 2010, 11:05 PM
Thanks for the reply Massimiliano, I understand your points, and think we are on the same page, but let me further clarify my situation.

Now I have the following structure
- Facility (Report)
- Assessment #1 (AssessmentID - PK)
- Photo #1
- Photo #2
- ...etc
- Assessment #2
- Photo #1
- ...etc
- Assessment #3
- ...etc

Each level is its own report with assessments being a subreport of facility (1 facility --> many assessments), and photos being a subreport of assessments (1 assessments --> many photos)

So I bind the facility data with success, bind the assessments data with success, the tricky part is that I have to bind the photos using the AssessmentID of #1, #2, #3, etc. I am trying to do this in the assessmentTable_ItemDataBound event. I have a panel in the the assessments table, and am trying to either (a) add the subReport dynamically to the panel or (b) place a SubReport placeholder in the panel, then initialize the report during that event.

The problem I am running into is that I have to get the Telerik.Reporting.Processing objects. Here's my code:
 
(a)
Telerik.Reporting.Processing.Panel reportpanel = (Telerik.Reporting.Processing.Panel)tab.ChildElements.Find("panel1", true).GetValue(i);
SubReport new_photo_report = new SubReport();
new_photo_report.ReportSource = new RMReports.AssessmentPhotos(dv, m_PhotoDirectory, m_EventID.ToString());
reportpanel.ChildElements.Add(new_photo_report);
It won't allow the "reportpanel.ChildElements.Add(new_photo_report);" line due to it cannot convert Telerik.Reporting.Processing.SubReport to Telerik.Reporting.SubReport

(b)
Telerik.Reporting.Processing.SubReport subreportbox = (Telerik.Reporting.Processing.SubReport)tab.ChildElements.Find("subReport3", true).GetValue(i);                   
subreportbox.ReportSource = new RMReports.AssessmentPhotos(dv, m_PhotoDirectory, m_EventID.ToString());
I won't allow subreportbox to be assigned a ReportSource (the property doesn't exist)

I feel like I am so close to finding the key, but it is still eluding me. Does anyone have any ideas or other ideas to accomplish this task?
Thanks in advance

Kris

0
Massimiliano Bassili
Top achievements
Rank 1
answered on 12 Aug 2010, 08:44 AM
Kris, I don't think dynamic adding of items in the processing stage would work. The whole idea of the reporting is that you have a template (the definition of the report), which when processed creates multiple counterparts for each report definition, so trying to mess with this process would not yield results.
I found a thread where something similar is shown with examples by Telerik: http://www.telerik.com/community/forums/reporting/telerik-reporting/data-source-business-objects.aspx.

Cheers!
0
Kris
Top achievements
Rank 1
answered on 17 Aug 2010, 03:43 PM
Thanks for the reply Massimiliano, I finally figured it out. For each assessment, I am dynamically creating a subreport for each. Then the subreport gets and displays the photos for that assessment. 

Now I just have to figure out how to not split up tables on separate pages.

Anyways, thanks for the help.

Kris
0
Kris
Top achievements
Rank 1
answered on 17 Aug 2010, 04:03 PM
I finally figured out a way to do it. For each assessment, I am dynamically adding a subreport for each. Then each subreport displays assessment details, and the photos for that assessment.

Now I just have to figure out how to prevent the table showing the data to stay together on one page(i.e. not split the photos onto separate pages).

Anyways, thanks for the help Massimiliano. 

Kris
Tags
General Discussions
Asked by
Kris
Top achievements
Rank 1
Answers by
Kris
Top achievements
Rank 1
Massimiliano Bassili
Top achievements
Rank 1
Share this question
or