How to hide part of detail section dynamically?

7 posts, 0 answers
  1. Imdad Turi
    Imdad Turi avatar
    29 posts
    Member since:
    Aug 2013

    Posted 11 Dec 2013 Link to this post

    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.
  2. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 14 Dec 2013 Link to this post

    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.

  3. DevCraft banner
  4. Imdad Turi
    Imdad Turi avatar
    29 posts
    Member since:
    Aug 2013

    Posted 16 Dec 2013 Link to this post

    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
  5. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 16 Dec 2013 Link to this post

    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.

  6. Imdad Turi
    Imdad Turi avatar
    29 posts
    Member since:
    Aug 2013

    Posted 17 Dec 2013 Link to this post

    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
  7. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 17 Dec 2013 Link to this post

    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.

  8. Imdad Turi
    Imdad Turi avatar
    29 posts
    Member since:
    Aug 2013

    Posted 17 Dec 2013 Link to this post

    Thanks Stef, Actually I have some issue regarding time. I will use expression as you suggested to avoid events.

    Imdad Turi
Back to Top
DevCraft banner