This question concerns a page-style / paging app and how to fake pages in a single diagram using node visibility switching.
I am working on an app that lets the user work on a number of diagrams which can be thought of as pages in a virtual document. Only one page / diagram should be visible at any time, and there are UI controls to step through the pages.
My server side generates a model for all pages in one hit, so there is no server-side requirement to round-trip as the user navigates the pages.
It seems to me that there are 2 options to fake-up pages,
1 - instantiate a new diagram per page, loading the model for that page as the user switches to the page, unload when they switch away to the next / prev page;
or
2 - use a single diagram and somehow indicate which diagram parts / nodes are on what page number, then manipulate visibility of the diagram parts in line with the page number that is on display.
I prefer option 2 for performance and lower complexity reasons but I will be happy to receive advice on option 1.
Re option 2, if this were a pure HTML solution I could assign a dummy CSS class to the nodes, e.g. ‘pageNo_1’ for all nodes on P1, and use something like JQuery to switch visibility of all elements not on the current page number. Does gojs have something like this.
This is kind of the approach I had in mind but I don’t know how to set a piece of arbitrary data on the nodes to represent the page no.
function showPage( pageNo ) {
<span =“Apple-tab-span” style=“white-space:pre”> for (var it = myDiagram.nodes; it.next(); ) {
<span =“Apple-tab-span” style=“white-space:pre”> var n = it.value; // n is now a Node or a Group
<span =“Apple-tab-span” style=“white-space:pre”>
<span =“Apple-tab-span” style=“white-space:pre”> if (n.<pageno?> !== pageNo) {
<span =“Apple-tab-span” style=“white-space:pre”> n.visible = false
<span =“Apple-tab-span” style=“white-space:pre”> }<span =“Apple-tab-span” style=“white-space:pre”>
<span =“Apple-tab-span” style=“white-space:pre”> else {
<span =“Apple-tab-span” style=“white-space:pre”> n.visible = true
<span =“Apple-tab-span” style=“white-space:pre”> }<span =“Apple-tab-span” style=“white-space:pre”>
<span =“Apple-tab-span” style=“white-space:pre”> }
}
Or should I be using the a pageNo property on the model element that represents the node ?
[For future searchers: keywords page paging paged arbitrary variable visible visibility]