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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- 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)

