New to Telerik Reporting? Download free 30-day trial

Expand/Collapse All Toggle Visibility Actions Simultaneously

Environment

Product Progress® Telerik® Reporting

Description

This article explains how to control all Drilldown report items with a single boolean Report Parameter.

Solution

You may use the ItemDataBinding event of the data item where you use the Toggle Visibility Action. For example, if you use ToggleVisibility to hide/show nested table groups in the Table table1 through the TextBoxes textBox11, and textBox17, you may use code like:

private void table1_ItemDataBinding(object sender, EventArgs e)
{
    var table = sender as Telerik.Reporting.Processing.Table;
    bool expand = (bool)table.Report.Parameters["Expand"].Value;

    ToggleVisibilityAction drillDownAction = (ToggleVisibilityAction)this.textBox11.Action;
    ExpandDrillDownAction(expand, drillDownAction);

    ToggleVisibilityAction drillDownAction17 = (ToggleVisibilityAction)this.textBox17.Action;
    ExpandDrillDownAction(expand, drillDownAction17);
}

private static void ExpandDrillDownAction(bool expand, ToggleVisibilityAction drillDownAction)
{
    drillDownAction.DisplayExpandedMark = expand;
    foreach (var t in drillDownAction.Targets.Cast<IToggleVisibilityTarget>())
    {
        if (t is ReportItemBase)
        {
            (t as ReportItemBase).Visible = expand;
        }

        if (t is TableGroup)
        {
            (t as TableGroup).Visible = expand;

        }
    }
}

At the moment when this event is raised the parameter values are already processed and known, and the properties of the definition items inside the data item (table1) can still be modified and taken into account in the further processing. The value of the Report Parameter that controls the visibility of the items is taken in the table event and its value is applied to the definition of the controlling items - textBox11 and textBox17 (see the ExpanAll sample in our GitHub repository). The former controls the Action that toggles the visibility of the outer table group, and the latter - of the inner table group. You may do the same also for deeper nested Actions by modifying the action settings in the definition of the corresponding controlling report item.

In this article