Main Content

Generate Table of Contents for Embedded Web View Report

The slreportgen.webview.EmbeddedWebViewDocument base class of an Embedded Web View report generator embeds JavaScript® in the generated Embedded Web View reports. In addition to generating other portions of the report, the JavaScript generates a table of contents from the document section headings. When you open the report in a web browser, the hyperlinked table of contents appears.

To use this feature, your report generator fillContent method must use Report API Chapter or Section objects, or DOM API Heading objects to begin the sections and subsections of the report. For example:

function fillContent(rpt)

import mlreportgen.dom.*
import mlreportgen.report.*

model = getExportModels(rpt);
model= model{1};
add(rpt, TitlePage("Title", [model " Report"], "Author",""));
finder = slreportgen.finder.ModelVariableFinder(model);

% Create a Variables Chapter
ch = Chapter("Variables");

while hasNext(finder)
    result = next(finder);
    % Create a section for the variable
    s = Section(result.Name);
    
    reporter = getReporter(result);
    add(s, reporter);
    
    % Add this section to the chapter
    add(ch, s);
end

% Add the chapter to the report
add(rpt, ch);
end

For other tasks to create your Embedded Web View generator, see:

To generate the Embedded Web View report, see Generate an Embedded Web View Report.