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

How to hide part of detail section dynamically?

6 Answers 654 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Imdad Turi
Top achievements
Rank 2
Imdad Turi asked on 11 Dec 2013, 02:32 PM
Hello every one and Telerik,
I am working on an invoice report, containing three type of charges(accessorial, freight and miscellaneous charges ), if a specific category of charges have no data i.e the invoice doesn't contain charges in accessorial , freight or miscellaneous charge category then that section should be invisible, the report should show the other two categories. how to handle it dynamically. in some case i have no accessorial while in some case i have no freight charges. Clients wants no empty fields on the report. Any one to help ???
what is the better way to handle it? should i make sections in detail section or there is any other batter?  if sections in detail section then how to make sections in detail section.
a snapshot of the report format is attached.

6 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 14 Dec 2013, 12:30 PM
Hello Imdad,

This layout can be achieved with three separate Table/Crosstab/List items in the report. If you need to bind a data from a single business object, you can use the approach described in the How to use ReportItem.DataObject property in expressions help article.

To hide a Table item when there is no data, set the Table.NoDataMessage property to an empty string and the Table.NoDataStyle.Visible property to false. Shrinking the Detail section height or moving consecutive items on the place of the hidden item can be handled with bindings to the needed properties as Height and Top. For more details take a look at the Collapse the container when hiding child report items KB article.

I hope this information helps you.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Imdad Turi
Top achievements
Rank 2
answered on 16 Dec 2013, 10:45 AM
Hello Stef,
I really appreciate your response but i handled the scenario with sub reports, each charge category is a Sub-report i.e Freight Charge subreport, Accessorial Charge Sub report and Miscellaneous CHarge Subreport , Now i am trying to hide sub-report if there is no data on the detail section of that sub-report. I have tried many threads but still unable to do it. Actually in the footer section i have another Sub-report that contains images. if there is no image associated with a invoice then an empty page comes at the end of the report. that empty page is a big headache for my client. I want to share my failed try if you can help in this regard, i will paste code below.

private void FreightChargeSubRpt_ItemDataBound(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.SubReport subReport = (Telerik.Reporting.Processing.SubReport)sender;
            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)subReport.InnerReport;
            //int a = report.ItemDefinition.Items.Find("detail", true).Length;
            subReport.Visible = report.ItemDefinition.Items.Find("detail", true).Length > 0;
            //subReport.Visible = report.ItemDefinition.Items[3].Items.Find("textBox19", true).Length > 0;
        }

this doesn't work for me, am i missing something or trying something wrong?

Thanks once again.

Imdad Turi
0
Stef
Telerik team
answered on 16 Dec 2013, 07:41 PM
Hello Imdad,

Test the following:
  1. Open the sub report and add the following binding to a proper report section e.g. Detail or GroupHeader sections:
    Property Path: Parent.Parent.Visible
    Expression: =Count(Fields.FieldIntheData)>0
  2. Shring the section containing the SubReport item as illustrated in the Collapse the container when hiding child report items KB article

I hope this helps you.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Imdad Turi
Top achievements
Rank 2
answered on 17 Dec 2013, 01:15 PM
Thank you very much Stef, that helped a lot. but below code also worked for me.
****CODE******
        private void AccessorialChargeSubRpt_ItemDataBound(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.SubReport subReport = (Telerik.Reporting.Processing.SubReport)sender;
            Telerik.Reporting.Processing.Report report = (Telerik.Reporting.Processing.Report)subReport.InnerReport;
            subReport.Visible = Telerik.Reporting.Processing.ElementTreeHelper.FindChildByName(report, "detail", true).Length > 0;
        }

**********************

Be Happy , have great time, hope you will help in future as well.

Thanks

Imdad Turi
0
Stef
Telerik team
answered on 17 Dec 2013, 02:51 PM
Hello Imdad,

Using events to modify the report once the processing has started is not recommended. Using expressions will save you time and issues if you have a Web project and use Out-Proc sessions state mode for instance - Design Considerations for Out-proc Session State. In addition expressions will be easier to maintain.

I hope this points you into the right direction.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Imdad Turi
Top achievements
Rank 2
answered on 17 Dec 2013, 03:06 PM
Thanks Stef, Actually I have some issue regarding time. I will use expression as you suggested to avoid events.

Imdad Turi
Tags
General Discussions
Asked by
Imdad Turi
Top achievements
Rank 2
Answers by
Stef
Telerik team
Imdad Turi
Top achievements
Rank 2
Share this question
or