mlreportgen.dom.Collapsible Class
Namespace: mlreportgen.dom
Description
Use an object of the mlreportgen.dom.Collapsible
class to specify the number of table rows
to collapse in an HTML table.
The mlreportgen.dom.Collapsible
class is a handle
class.
Class Attributes
HandleCompatible | true |
ConstructOnLoad | true |
For information on class attributes, see Class Attributes.
Creation
Input Arguments
Number of rows after the formatted row to collapse, specified as an integer.
Properties
Number of rows to collapse, specified as an integer. The value of this property denotes the number of rows after the formatted row that collapse when you click the formatted row.
Attributes:
NonCopyable | true |
Data Types: uint64
Tag, specified as a character vector or string scalar. The DOM API generates a
session-unique tag as part of the creation of this object. The generated tag has the
form CLASS:ID
, where
CLASS
is the object class and
ID
is the value of the
Id
property of the object. Use this value to help identify
where an issue occurs during document generation.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char
| string
Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char
| string
Examples
This example shows how to create HTML tables with collapsible rows or with nested collapsible rows.
Create Table with Collapsible Rows
Import the mlreportgen.report
and mlreportgen.dom
namespaces so that you do not have to include the fully qualified names for the object constructors and methods.
import mlreportgen.report.* import mlreportgen.dom.*
Create an HTML document.
rpt = Report("myCollapsibleTables","html"); open(rpt);
Create the first chapter.
chap1 = Chapter("Table with collapsible rows");
Specify the table data.
collapsibleTableData = { ... "Parent Row: Click to expand next 2 rows"; ... " Collapsible Content for Parent Row"; ... " More Collapsible Content for Parent Row"; ... "Static Row" ... };
Create the table and define basic styling. Use WhiteSpace("preserve")
to keep the leading whitespaces in the second and third rows.
tbl = Table(collapsibleTableData); tbl.Border = "solid"; tbl.RowSep = "solid"; tbl.ColSep = "solid"; tbl.Style = [tbl.Style {WhiteSpace("preserve")}];
Make the first row of the table collapsible, so that clicking on it collapses the following two rows.
row1 = tbl.row(1); row1.Style = [row1.Style {Collapsible(2)}];
Append the table to the chapter and the chapter to the report.
append(chap1,tbl); append(rpt,chap1);
Close and view the report.
close(rpt); rptview(rpt);
To open or close a group of collapsible rows, click the parent row. Collapsible rows have gray highlighting when you point to them.
This image shows what the table looks like in the report when fully expanded and when the second row is collapsed.
Table with all rows fully expanded | Table with the second row collapsed |
Version History
Introduced in R2025a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)