1 | <!DOCTYPE html>
|
2 | <html lang="en">
|
3 | <head>
|
4 | <meta charset="utf-8"/>
|
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover"/>
|
6 | <meta name="description" content="TypeScript: Allow users to scroll the items in a Table Panel."/>
|
7 | <link rel="stylesheet" href="../assets/css/style.css"/>
|
8 |
|
9 | <title>Scrolling Table</title>
|
10 | </head>
|
11 |
|
12 | <body>
|
13 |
|
14 | <nav id="navTop" class="w-full z-30 top-0 text-white bg-nwoods-primary">
|
15 | <div class="w-full container max-w-screen-lg mx-auto flex flex-wrap sm:flex-nowrap items-center justify-between mt-0 py-2">
|
16 | <div class="md:pl-4">
|
17 | <a class="text-white hover:text-white no-underline hover:no-underline
|
18 | font-bold text-2xl lg:text-4xl rounded-lg hover:bg-nwoods-secondary " href="../">
|
19 | <h1 class="mb-0 p-1 ">GoJS</h1>
|
20 | </a>
|
21 | </div>
|
22 | <button id="topnavButton" class="rounded-lg sm:hidden focus:outline-none focus:ring" aria-label="Navigation">
|
23 | <svg fill="currentColor" viewBox="0 0 20 20" class="w-6 h-6">
|
24 | <path id="topnavOpen" fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM9 15a1 1 0 011-1h6a1 1 0 110 2h-6a1 1 0 01-1-1z" clip-rule="evenodd"></path>
|
25 | <path id="topnavClosed" class="hidden" fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path>
|
26 | </svg>
|
27 | </button>
|
28 | <div id="topnavList" class="hidden sm:block items-center w-auto mt-0 text-white p-0 z-20">
|
29 | <ul class="list-reset list-none font-semibold flex justify-end flex-wrap sm:flex-nowrap items-center px-0 pb-0">
|
30 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../learn/">Learn</a></li>
|
31 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../samples/">Samples</a></li>
|
32 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../intro/">Intro</a></li>
|
33 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../api/">API</a></li>
|
34 | <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/products/register.html">Register</a></li>
|
35 | <li class="p-1 sm:p-0"><a class="topnav-link" href="../download.html">Download</a></li>
|
36 | <li class="p-1 sm:p-0"><a class="topnav-link" href="https://forum.nwoods.com/c/gojs/11">Forum</a></li>
|
37 | <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/contact.html"
|
38 | target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/contact.html', 'contact');">Contact</a></li>
|
39 | <li class="p-1 sm:p-0"><a class="topnav-link" href="https://www.nwoods.com/sales/index.html"
|
40 | target="_blank" rel="noopener" onclick="getOutboundLink('https://www.nwoods.com/sales/index.html', 'buy');">Buy</a></li>
|
41 | </ul>
|
42 | </div>
|
43 | </div>
|
44 | <hr class="border-b border-gray-600 opacity-50 my-0 py-0" />
|
45 | </nav>
|
46 | <div class="md:flex flex-col md:flex-row md:min-h-screen w-full max-w-screen-xl mx-auto">
|
47 | <div id="navSide" class="flex flex-col w-full md:w-48 text-gray-700 bg-white flex-shrink-0"></div>
|
48 |
|
49 |
|
50 |
|
51 |
|
52 | <div class="p-4 w-full">
|
53 | <div id="sample">
|
54 | <div id="myDiagramDiv" style="border: solid 1px black; width:100%; height:600px"></div>
|
55 | <p>
|
56 | This makes use of the "ScrollingTable" Panel defined in <a href="ScrollingTable.ts">ScrollingTable.ts</a>.
|
57 | The "AutoRepeatButton" Panel is also defined in that file. Each node is resizable.
|
58 | </p>
|
59 | <p>
|
60 | Note how links connect particular port elements on each node. When an element has a <a>GraphObject.index</a> less than
|
61 | the <a>Panel.topIndex</a>, the panel arranges it be zero sized at the top of the panel. Similarly, elements beyond the
|
62 | last item in the panel are arranged to be at the end of the list, which may be at the bottom of the panel.
|
63 | </p>
|
64 | </div>
|
65 |
|
66 | <script type="module" id="code">
|
67 | import * as go from "../release/go-module.js";
|
68 | import "./ScrollingTable.js";
|
69 |
|
70 | if (window.goSamples) goSamples();
|
71 | const $ = go.GraphObject.make;
|
72 |
|
73 | const myDiagram = $(go.Diagram, 'myDiagramDiv', {
|
74 | 'PartResized': function(e) {
|
75 | const node = e.subject;
|
76 | const scroller = node.findObject('SCROLLER');
|
77 | if (scroller !== null)
|
78 | scroller._updateScrollBar(scroller.findObject('TABLE'));
|
79 | }
|
80 | });
|
81 |
|
82 | myDiagram.nodeTemplate =
|
83 | $(go.Node, 'Vertical',
|
84 | {
|
85 | selectionObjectName: 'SCROLLER',
|
86 | resizable: true, resizeObjectName: 'SCROLLER',
|
87 | portSpreading: go.Node.SpreadingNone
|
88 | },
|
89 | new go.Binding('location').makeTwoWay(),
|
90 | $(go.TextBlock,
|
91 | { font: 'bold 14px sans-serif' },
|
92 | new go.Binding('text', 'key')),
|
93 | $(go.Panel, 'Auto',
|
94 | $(go.Shape, { fill: 'white' }),
|
95 | $('ScrollingTable',
|
96 | {
|
97 | name: 'SCROLLER',
|
98 | desiredSize: new go.Size(NaN, 60),
|
99 | stretch: go.GraphObject.Fill,
|
100 | defaultColumnSeparatorStroke: 'gray',
|
101 | defaultColumnSeparatorStrokeWidth: 0.5
|
102 | },
|
103 | new go.Binding('TABLE.itemArray', 'items'),
|
104 | new go.Binding('TABLE.column', 'left', function(left) { return left ? 2 : 0; }),
|
105 | new go.Binding('desiredSize', 'size').makeTwoWay(),
|
106 | {
|
107 | 'TABLE.itemTemplate':
|
108 | $(go.Panel, 'TableRow',
|
109 | {
|
110 | defaultStretch: go.GraphObject.Horizontal,
|
111 | fromSpot: go.Spot.LeftRightSides, toSpot: go.Spot.LeftRightSides,
|
112 | fromLinkable: true, toLinkable: true
|
113 | },
|
114 | new go.Binding('portId', 'name'),
|
115 | $(go.TextBlock, { column: 0 }, new go.Binding('text', 'name')),
|
116 | $(go.TextBlock, { column: 1 }, new go.Binding('text', 'value'))),
|
117 | 'TABLE.defaultColumnSeparatorStroke': 'gray',
|
118 | 'TABLE.defaultColumnSeparatorStrokeWidth': 0.5,
|
119 | 'TABLE.defaultRowSeparatorStroke': 'gray',
|
120 | 'TABLE.defaultRowSeparatorStrokeWidth': 0.5,
|
121 | 'TABLE.defaultSeparatorPadding': new go.Margin(1, 3, 0, 3)
|
122 | })));
|
123 |
|
124 | myDiagram.model = $(go.GraphLinksModel, {
|
125 | linkFromPortIdProperty: 'fromPort',
|
126 | linkToPortIdProperty: 'toPort',
|
127 | nodeDataArray: [
|
128 | {
|
129 | key: 'Alpha', left: true, location: new go.Point(0, 0), size: new go.Size(100, 50),
|
130 | items: [
|
131 | { name: 'A', value: 1 },
|
132 | { name: 'B', value: 2 },
|
133 | { name: 'C', value: 3 },
|
134 | { name: 'D', value: 4 },
|
135 | { name: 'E', value: 5 },
|
136 | { name: 'F', value: 6 },
|
137 | { name: 'G', value: 7 }
|
138 | ]
|
139 | },
|
140 | {
|
141 | key: 'Beta', location: new go.Point(150, 0),
|
142 | items: [
|
143 | { name: 'Aa', value: 1 },
|
144 | { name: 'Bb', value: 2 },
|
145 | { name: 'Cc', value: 3 },
|
146 | { name: 'Dd', value: 4 },
|
147 | { name: 'Ee', value: 5 },
|
148 | { name: 'Ff', value: 6 },
|
149 | { name: 'Gg', value: 7 },
|
150 | { name: 'Hh', value: 8 },
|
151 | { name: 'Ii', value: 9 },
|
152 | { name: 'Jj', value: 10 },
|
153 | { name: 'Kk', value: 11 },
|
154 | { name: 'Ll', value: 12 },
|
155 | { name: 'Mm', value: 13 },
|
156 | { name: 'Nn', value: 14 }
|
157 | ]
|
158 | }
|
159 | ],
|
160 | linkDataArray: [
|
161 | { from: 'Alpha', fromPort: 'D', to: 'Beta', toPort: 'Ff' },
|
162 | { from: 'Alpha', fromPort: 'A', to: 'Beta', toPort: 'Nn' },
|
163 | { from: 'Alpha', fromPort: 'G', to: 'Beta', toPort: 'Aa' }
|
164 | ]
|
165 | });
|
166 |
|
167 | window.myDiagram = myDiagram;
|
168 | </script>
|
169 | </div>
|
170 |
|
171 |
|
172 | </div>
|
173 | </body>
|
174 |
|
175 | <script src="../assets/js/goSamples.js"></script>
|
176 | </html>
|