Create Hyperlinks for Embedded Web View Reports
To create one-way and two-way hyperlinks between the document pane and the web view embedded in the report, use these methods. These linking methods are inherited from the slreportgen.webview.EmbeddedWebViewDocument
base class of the report generator.
createDiagramTwoWayLink
— Create a two-way link between a document location and a diagram in the embedded web view. Clicking a link created by this method in the document opens the target diagram in the web view. Clicking in the diagram scrolls the document pane to the target document location.createElementTwoWayLink
— Create a two-way link between a document location and a diagram element in the embedded web view. Clicking a link created by this method in a document opens the diagram containing the model element and flashes the element. Clicking the element in the diagram scrolls the document pane to the target document location.createDiagramLink
— Creates a link from the document to a diagram in the embedded web view.createElementLink
— Creates a link from the document to an element of a block diagram in the embedded web view.
Run the following command to access the supporting files used in this example.
openExample('rptgenext/SimulinkReportGeneratorFilesExample');
In the following example class, ExampleWebView
, the fillcontent
method uses createDiagramTwoWayLink
and createElementTwoWayLink
to create two-way links between the document panel and the embedded web view in an embedded web view report. To create one-way links from the document panel to the embedded web view, replace createDiagramTwoWayLink
with createDiagramLink
and createElementTwoWayLink
with createElementLink
.
classdef ExampleWebView < slreportgen.webview.EmbeddedWebViewDocument methods function wvdoc = ExampleWebView(reportPath,modelName) % Invoke the EmbeddedWebViewDocument constructor, which % saves the report path and model name for use by the % report's fill methods. wvdoc@slreportgen.webview.EmbeddedWebViewDocument(reportPath,modelName); end function fillContent(wvdoc) % Fill the Content hole in the report template with design % variable information. You can use DOM or Report API methods % to create, format, add, and append content to this report. [~, handles] = getExportDiagrams(wvdoc); n = numel(handles); for i = 1:n diagHandle = handles{i}; diagHeading = createDiagramTwoWayLink(wvdoc,diagHandle, ... mlreportgen.dom.Heading(2,get_param(diagHandle,'Name'))); append(wvdoc,diagHeading); blockFinder = slreportgen.finder.BlockFinder(diagHandle); while hasNext(blockFinder) r = next(blockFinder); elemHandle = r.Object; elemHeading = createElementTwoWayLink(wvdoc,elemHandle, ... mlreportgen.dom.Heading(3,get_param(elemHandle,'Name'))); append(wvdoc,elemHeading); end end end end end
This code creates an embedded web view report for the slrgex_vdp
model using the ExampleWebView
class.
model = 'slrgex_vdp'; open_system(model); wvdoc = ExampleWebView('myReport',model); open(wvdoc); fill(wvdoc); close(wvdoc); rptview(wvdoc);
Here is the report:
To use the links in the report:
Click a diagram name in the document pane, for example,
More Info
. The associated diagram opens.In the embedded web view, on the
More Info
tab, clickslrgex_vdp
.The
slrgex_vdp
diagram opens andslrgex_vdp
is highlighted briefly in the document pane.Click
Square
in the document pane, the Square block is highlighted in the embedded web view.In the embedded web view, double-click the Mu block. The
Mu
link in the document pane is highlighted briefly.
For other tasks to create your embedded web view generator, see:
To generate an embedded web view report, see Generate Embedded Web View Reports.
See Also
slreportgen.webview.EmbeddedWebViewDocument