將展開或摺疊動作加入項目中 (報表產生器及 SSRS)Add an Expand or Collapse Action to an Item (Report Builder and SSRS)

您可以讓使用者以互動方式展開或摺疊報表項目,或者針對資料表或矩陣,展開或摺疊與群組關聯的資料列和資料行。You can enable a user to interactively expand or collapse report items, or expand or collapse rows and columns associated with a group for a table or matrix. 若要讓使用者展開或摺疊項目,您可以設定該項目的可見性屬性。To allow users to expand or collapse an item, you set the visibility properties for that item. 設定可見性適用於 HTML 報表檢視器,有時稱為 「向下鑽研」 (Drilldown) 動作。Setting visibility works in an HTML report viewer, and is sometimes called a drilldown action.

在報表設計檢視中,請指定要顯示展開和摺疊切換圖示之文字方塊的名稱。In report design view, you specify the name of the text box where you want to display the expand and collapse toggle icons. 在轉譯過的報表中,文字方塊除了其內容之外,還會顯示一個加號 (+) 或一個減號 (-)。In the rendered report, the text box displays a plus (+) or minus (-) sign in addition to its contents. 當使用者按一下切換時,報表顯示會重新整理,根據報表項目的目前可見性設定,顯示或隱藏報表項目。When the user clicks the toggle, the report display is refreshed to show or hide the report item, based on the current visibility settings for items in the report.

展開和摺疊動作通常用於一開始只顯示摘要資料,以及讓使用者按一下加號來顯示詳細資料。Typically, the expand and collapse action is used to initially display only summary data and to enable the user to click the plus sign to show detail data. 例如,您一開始可以隱藏顯示圖表值的資料表,或針對包含巢狀資料列或資料行群組的資料表隱藏子群組,如同在向下鑽研報表一樣。For example, you can initially hide a table that displays values for a chart, or hide child groups for a table with nested row or column groups, as in a drilldown report.

注意

您可以在報表產生器以及 SQL Server Data Tools 的報表設計師中建立和修改分頁報表定義檔 (.rdl)。You can create and modify paginated report definition (.rdl) files in Report Builder and in Report Designer in SQL Server Data Tools. 每種撰寫環境都會提供不同的方式來建立、開啟和儲存報表與相關的項目。Each authoring environment provides different ways to create, open, and save reports and related items.

若要將展開和摺疊動作加入至群組中To add expand and collapse action to a group

  1. 在報表設計檢視中,按一下資料表或矩陣即可選取它。In report design view, click the table or matrix to select it. [群組] 窗格會顯示資料列和資料行群組。The Grouping pane displays the row and column groups.

    群組窗格Grouping Pane

    如果未顯示 [群組] 窗格,請按一下[檢視] 功能表,然後按一下 [群組] 。If the Grouping pane does not appear, click the View menu and then click Grouping.

  2. 以滑鼠右鍵按一下 [群組] 窗格標題列的任意位置,然後按一下 [進階]。Right-click anywhere in the title bar of the Grouping pane, and then click Advanced. [群組] 窗格模式會切換以便在設計介面上,顯示資料列和資料行的基礎顯示結構。The Grouping pane mode toggles to show the underlying display structure for rows and columns on the design surface.

    含 [進階模式] 功能表的 [群組] 窗格Grouping Pane with Advanced Mode menu

  3. 在適當的群組窗格中,按一下您要隱藏相關聯資料列或資料行之資料列群組或資料行群組的名稱。In the appropriate group pane, click the name of the row group or column group for which you want to hide the associated rows or columns. 群組選定之後,[屬性] 窗格會顯示 [Tablix 成員] 屬性。The group is selected and the Properties pane shows the Tablix Member properties.

    注意

    如果看不到 [屬性] 窗格,請按一下功能區上的 [檢視],然後按一下 [屬性]。If you do not see the Properties pane, click View on the Ribbon and then click Properties.

  4. [隱藏] 中,選擇下列其中一個選項來設定第一次執行報表時,此報表項目的可見性:In Hidden, choose one of the following options to set the visibility of this report item the first time you run a report:

    • 選取 [False] 來顯示報表項目。Select False to display the report item.

    • 選取 [True] 來隱藏報表項目。Select True to hide the report item.

    • 選取 [<運算式>] 開啟 [運算式] 對話方塊,即可建立在執行階段評估的運算式來決定可見度。Select <Expression> to open the Expression dialog box to create an expression that is evaluated at run time to determine the visibility.

  5. ToggleItem中,從下拉式方塊選取要加入切換影像之目標文字方塊的名稱。In ToggleItem, from the drop-down box, select the name of a text box to which to add the toggle image.

    在下圖中,色彩資料列群組已設定為可讓使用者展開和摺疊相關聯的資料列。In the following image, the Color row group is configured enable users to expand and collapse associated rows.

    設定要展開的資料列群組Configuring a row group to be expanded

    注意

    具有切換影像的文字方塊不能是您要隱藏相關聯資料列或資料行的資料列或資料行群組。The text box with the toggle image cannot be the row or column group for which you want to hide the associated rows or columns. 它必須在隱藏項目的相同群組中,或在上階群組中。It must either be in the same group as the item that is being hidden or in an ancestor group. 例如,若要切換與子群組相關之資料列的可見性,請選取與父群組有關之資料列中的文字方塊。For example, to toggle visibility of rows associated with a child group, select a text box in a row associated with the parent group.

  6. 若要測試切換,請執行報表,然後按一下包含切換影像的文字方塊。To test the toggle, run the report and click the text box with the toggle image. 報表顯示會重新整理,以顯示包含已切換之可見性的資料列群組和資料行群組。The report display refreshes to show row groups and column groups with their toggled visibility.

    執行含可展開之資料列群組的報表Running report with expandable row group

若要將展開和摺疊動作加入至報表項目中To add expand and collapse action to a report item

  1. 在報表設計檢視中,以滑鼠右鍵按一下要顯示或隱藏的報表項目,然後按一下 [<報表項目> 屬性]。In report design view, right-click the report item to show or hide, and then click <report item> Properties. 該報表項目的 [<報表項目> 屬性] 對話方塊隨即開啟。The <report item> Properties dialog box for the report item opens.

  2. 按一下 [可見性]Click Visibility.

  3. [一開始執行報表時] 中,選擇下列其中一個選項來設定第一次執行報表時,此報表項目的可見性:In When the report is initially run, choose one of the following options to set the visibility of this report item the first time you run a report:

    • 選取 [顯示] 來顯示報表項目。Select Show to display the report item.

    • 選取 [隱藏] 來隱藏報表項目。Select Hide to hide the report item.

    • 選取 [依據運算式顯示或隱藏] ,使用在執行階段評估的運算式來決定可見性。Select Show or hide based on an expression to use an expression evaluated at run time to determine the visibility. 按一下 (fx) 開啟 [運算式] 對話方塊,即可建立運算式。Click (fx) to open the Expression dialog box to create an expression.

      注意

      當您指定可見性的運算式時,會設定報表項目的 Hidden 屬性。When you specify an expression for visibility, you are setting the Hidden property of the report item. 運算式會評估為 BooleanTrue 來隱藏項目,以及 False 來顯示項目。The expression evaluates to a Boolean value of True to hide the item and False to show the item.

  4. 在 [此報表項目可以切換顯示] 中,從下拉式方塊鍵入或選取報表中要顯示切換影像的文字方塊名稱;例如 Textbox1。In Display can be toggled by this report item, from the drop-down box, type or select the name of a text box in the report in which to display a toggle image; for example, Textbox1.

    在下圖中,資料表已設定為讓使用者可展開及摺疊該資料表。In the following image, the table is configured to enable users to expand and collapse it. [Products 資料表] 文字方塊可以切換資料表的顯示。The display of the table is toggled by the Products Table text box.

    設定要展開的報表資料表Configure a report table to be expanded

    注意

    您選擇的文字方塊必須位於此報表項目的目前或包含範圍 (最高至報表主體 (包含))。The text box that you choose must be in the current or containing scope for this report item (up to and including the report body). 例如,若要切換圖表的可見性,請選取與圖表位於相同涵蓋範圍的文字方塊,例如,報表主體或矩形。For example, to toggle visibility of a chart, select a text box that is in the same containing scope as the chart; for example, the report body or a rectangle. 此文字方塊必須位於相同或更高的容器階層中。The text box must be in the same container hierarchy or higher.

  5. 若要測試切換,請執行報表,然後按一下包含切換影像的文字方塊。To test the toggle, run the report and click the text box with the toggle image. 報表顯示會重新整理,以顯示包含已切換之可見性的報表項目。The report display refreshes to show report items with their toggled visibility.

    執行含有展開的資料表的報表Running report with an expanding table

另請參閱See Also

向下鑽研動作 (報表產生器及 SSRS) Drilldown Action (Report Builder and SSRS)
隱藏項目 (報表產生器及 SSRS)Hide an Item (Report Builder and SSRS)