react-graph-grid 0.1.9 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -15
- package/index.js +20 -0
- package/package.json +4 -11
- package/src/Base.jsx +81 -0
- package/src/Card.jsx +333 -0
- package/src/Dropdown.jsx +339 -0
- package/src/FieldEdit.jsx +376 -0
- package/src/Graph.jsx +482 -0
- package/src/Grid.jsx +887 -0
- package/src/GridCD.jsx +180 -0
- package/src/GridDB.jsx +897 -0
- package/src/GridFE.jsx +753 -0
- package/src/GridFL.jsx +468 -0
- package/src/GridGR.jsx +311 -0
- package/src/GridPK.jsx +414 -0
- package/src/Modal.jsx +511 -0
- package/src/Overlay.jsx +140 -0
- package/src/Tests/DebugApp.jsx +332 -0
- package/src/Tests/TestData.jsx +243 -0
- package/src/Themes/DefaultGridTheme.jsx +36 -0
- package/src/Themes/Images.jsx +438 -0
- package/src/Themes/Translate.jsx +76 -0
- package/src/css/default.css +951 -0
- package/src/main.jsx +10 -0
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { TestData } from '../Tests/TestData';
|
|
3
|
+
import { Overlay } from '../Overlay';
|
|
4
|
+
import { Modal } from '../Modal';
|
|
5
|
+
import { Dropdown } from '../Dropdown';
|
|
6
|
+
import { Grid } from '../Grid';
|
|
7
|
+
import { GridGR } from '../GridGR';
|
|
8
|
+
import { GridDB } from '../GridDB';
|
|
9
|
+
import { GridFL } from '../GridFL';
|
|
10
|
+
import { GridFE } from '../GridFE';
|
|
11
|
+
import { GridCD } from '../GridCD';
|
|
12
|
+
import { FieldEdit } from '../FieldEdit';
|
|
13
|
+
|
|
14
|
+
export function DebugApp() {
|
|
15
|
+
const [state, setState] = useState({ menuItem: - 2 });
|
|
16
|
+
|
|
17
|
+
window._logEnabled = true;
|
|
18
|
+
|
|
19
|
+
const GetFamily = function (e) {
|
|
20
|
+
return new Promise(function (resolve, reject) {
|
|
21
|
+
|
|
22
|
+
const rows = new TestData().getFamily(e);
|
|
23
|
+
|
|
24
|
+
if (rows != null) {
|
|
25
|
+
resolve(rows);
|
|
26
|
+
} else {
|
|
27
|
+
reject(Error("Error getting rows"));
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const GetButtons = function () {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
id: 1,
|
|
36
|
+
name: 'info',
|
|
37
|
+
title: 'Persone Info',
|
|
38
|
+
label: 'Persone Info',
|
|
39
|
+
click: function (e) {
|
|
40
|
+
const selRow = e.grid.selectedRowIndex >= 0 && e.grid.rows.length > 0 ? e.grid.rows[e.grid.selectedRowIndex] : null;
|
|
41
|
+
if (!selRow) return;
|
|
42
|
+
|
|
43
|
+
alert(`Persone Name = ${selRow.Name}, Persone Birth Day = ${selRow.Date}`);
|
|
44
|
+
},
|
|
45
|
+
getDisabled: function (e) {
|
|
46
|
+
return !e.grid.rows || e.grid.rows.length <= 0;
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 2,
|
|
51
|
+
name: 'clear',
|
|
52
|
+
title: 'Clear console',
|
|
53
|
+
label: 'Clear console',
|
|
54
|
+
click: function () {
|
|
55
|
+
console.clear();
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const GetCities = function (e) {
|
|
62
|
+
return new Promise(function (resolve, reject) {
|
|
63
|
+
|
|
64
|
+
const rows = new TestData().getCity(e);
|
|
65
|
+
|
|
66
|
+
if (rows != null) {
|
|
67
|
+
resolve(rows);
|
|
68
|
+
} else {
|
|
69
|
+
reject(Error("Error getting rows"));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const GetCityColumns = function () {
|
|
75
|
+
return new TestData().GetCityColumns();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const GetFamilyColumns = function () {
|
|
79
|
+
return new TestData().GetFamilyColumns();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const ResetColumnsOrder = function () {
|
|
83
|
+
const grid = window.gridComponent;
|
|
84
|
+
if (!grid) return;
|
|
85
|
+
|
|
86
|
+
grid.resetColumnsOrderToDefault();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const ResetColumnsWidths = function () {
|
|
90
|
+
const grid = window.gridComponent;
|
|
91
|
+
if (!grid) return;
|
|
92
|
+
|
|
93
|
+
grid.resetColumnsWidthsToDefault();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const GetPopupItems = function () {
|
|
97
|
+
return new Promise(function (resolve) {
|
|
98
|
+
|
|
99
|
+
const items = [
|
|
100
|
+
{ id: 1, text: 'test 1 item' },
|
|
101
|
+
{ id: 2, text: 'test 2 item' },
|
|
102
|
+
{ id: 3, text: 'test 3 item' },
|
|
103
|
+
{ id: 4, text: 'test 4 item' },
|
|
104
|
+
{ id: 5, text: 'test 5 item' }
|
|
105
|
+
];
|
|
106
|
+
resolve(items);
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const drawGridInModal = function () {
|
|
111
|
+
return (
|
|
112
|
+
<>
|
|
113
|
+
<div className="div-on-menu">
|
|
114
|
+
<button onClick={() => { console.clear() }} className="modal-window-footer-button">Clear console</button>
|
|
115
|
+
</div>
|
|
116
|
+
<Grid getRows={GetFamily}
|
|
117
|
+
init={(grid) => { window.gridComponent = grid }}
|
|
118
|
+
></Grid>
|
|
119
|
+
</>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const drawDropdownInModal = function (wnd) {
|
|
124
|
+
return (
|
|
125
|
+
<>
|
|
126
|
+
<div className="div-on-menu">
|
|
127
|
+
<button onClick={() => { console.clear() }} className="modal-window-footer-button">Clear console</button>
|
|
128
|
+
<button onClick={(e) => { wnd.ddComponent.popup(e); }} className="modal-window-footer-button">Show Dropdown</button>
|
|
129
|
+
</div>
|
|
130
|
+
<div>
|
|
131
|
+
{
|
|
132
|
+
wnd.ddComponent && wnd.ddComponent.clickedItem ? <span>{'Item Clicked : ' + wnd.ddComponent.clickedItem}</span> : <></>
|
|
133
|
+
}
|
|
134
|
+
</div>
|
|
135
|
+
<Dropdown init={(dd) => { wnd.ddComponent = dd; }} getItems={GetPopupItems}
|
|
136
|
+
onItemClick={(e) => { /*console.log('Item clicked: ' + e.itemId); */e.self.clickedItem = e.itemId; wnd.refreshState(); }}
|
|
137
|
+
>
|
|
138
|
+
</Dropdown>
|
|
139
|
+
</>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const drawClearConsole = function () {
|
|
144
|
+
return (
|
|
145
|
+
<button onClick={() => { console.clear() }} className="modal-window-footer-button">Clear console</button>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const drawTest = function () {
|
|
150
|
+
return (<></>);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
154
|
+
const getTestApp = () => {
|
|
155
|
+
console.log('state == ' + state.menuItem);
|
|
156
|
+
switch (state.menuItem) {
|
|
157
|
+
case 0:
|
|
158
|
+
return <></>
|
|
159
|
+
case 1:
|
|
160
|
+
return (
|
|
161
|
+
<>
|
|
162
|
+
<div className="div-on-menu">
|
|
163
|
+
1. Drag column to reorder
|
|
164
|
+
2. Doubleclick on divider to autowidth
|
|
165
|
+
</div>
|
|
166
|
+
<div className="div-on-menu">
|
|
167
|
+
<button onClick={() => ResetColumnsOrder()} className="modal-window-footer-button">Reset columns order</button>
|
|
168
|
+
<button onClick={() => ResetColumnsWidths()} className="modal-window-footer-button">Reset columns widths</button>
|
|
169
|
+
{drawClearConsole()}
|
|
170
|
+
</div>
|
|
171
|
+
<Grid getRows={GetFamily} init={(grid) => { window.gridComponent = grid; }}></Grid>
|
|
172
|
+
</>
|
|
173
|
+
)
|
|
174
|
+
case 2:
|
|
175
|
+
return (
|
|
176
|
+
<>
|
|
177
|
+
<div className="div-on-menu">
|
|
178
|
+
{drawClearConsole()}
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<Overlay init={(ovl) => { window.overlayComponent = ovl }} closeWhenEscape={true} closeWhenClick={true}></Overlay>
|
|
182
|
+
</>
|
|
183
|
+
)
|
|
184
|
+
case 3:
|
|
185
|
+
return (
|
|
186
|
+
<>
|
|
187
|
+
<Modal uid="m01" isModal={true} renderContent={() => { return drawGridInModal() }} closeWhenEscape={true}
|
|
188
|
+
pos={{ x: 100, y: 100, w: 600, h: 450 }} title='Modal Grid'></Modal>
|
|
189
|
+
</>
|
|
190
|
+
)
|
|
191
|
+
case 4:
|
|
192
|
+
return (
|
|
193
|
+
<>
|
|
194
|
+
<Modal uid="m02" isModal={true} title="Dropdown" renderContent={(wnd) => { return drawDropdownInModal(wnd) }} closeWhenEscape={true}
|
|
195
|
+
dimensionsByContent={true}
|
|
196
|
+
pos={{ x: 100, y: 100, w: 300, h: 250 }}></Modal>
|
|
197
|
+
</>
|
|
198
|
+
)
|
|
199
|
+
case 5:
|
|
200
|
+
return (
|
|
201
|
+
<>
|
|
202
|
+
<div className="div-on-menu">
|
|
203
|
+
Change the active record in the parent grid to see the child rows.
|
|
204
|
+
</div>
|
|
205
|
+
<div className="div-on-menu">
|
|
206
|
+
{drawClearConsole()}
|
|
207
|
+
</div>
|
|
208
|
+
<div className="div-with-grid">
|
|
209
|
+
<GridGR uid="people" getRows={GetFamily}></GridGR>
|
|
210
|
+
</div>
|
|
211
|
+
<div className="div-with-grid">
|
|
212
|
+
<GridGR uid="cities" parentGrids="people" getRows={GetCities} getColumns={GetCityColumns}></GridGR>
|
|
213
|
+
</div>
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
case 6:
|
|
217
|
+
return (
|
|
218
|
+
<>
|
|
219
|
+
<div className="div-on-menu">
|
|
220
|
+
Grid with pager, pocket and sortable columns. Hold shift to sort by multiple columns.
|
|
221
|
+
</div>
|
|
222
|
+
<div className="div-with-grid">
|
|
223
|
+
<GridDB getRows={GetFamily} buttons={GetButtons()} getColumns={GetFamilyColumns} multi={true}></GridDB>
|
|
224
|
+
</div>
|
|
225
|
+
</>
|
|
226
|
+
);
|
|
227
|
+
case 7:
|
|
228
|
+
return (
|
|
229
|
+
<>
|
|
230
|
+
<div className="div-on-menu">
|
|
231
|
+
Grid with column filters.
|
|
232
|
+
</div>
|
|
233
|
+
<div className="div-with-grid">
|
|
234
|
+
<GridFL getRows={GetFamily} buttons={GetButtons()} getColumns={GetFamilyColumns}></GridFL>
|
|
235
|
+
</div>
|
|
236
|
+
</>
|
|
237
|
+
);
|
|
238
|
+
case 8:
|
|
239
|
+
return (
|
|
240
|
+
<>
|
|
241
|
+
<Modal uid="m01" isModal={true} closeWhenEscape={true}
|
|
242
|
+
renderContent={() => {
|
|
243
|
+
return (
|
|
244
|
+
<div className="div-with-grid">
|
|
245
|
+
<span>Persona</span>
|
|
246
|
+
<FieldEdit
|
|
247
|
+
column={{
|
|
248
|
+
id: 1,
|
|
249
|
+
name: 'Persona',
|
|
250
|
+
getRows: GetFamily,
|
|
251
|
+
refKeyField: 'Id',
|
|
252
|
+
refNameField: 'Name',
|
|
253
|
+
type: 'lookup',
|
|
254
|
+
}}
|
|
255
|
+
>
|
|
256
|
+
</FieldEdit>
|
|
257
|
+
<br></br>
|
|
258
|
+
<span>Age</span>
|
|
259
|
+
<FieldEdit
|
|
260
|
+
column={{
|
|
261
|
+
id: 2,
|
|
262
|
+
name: 'Age',
|
|
263
|
+
}}
|
|
264
|
+
>
|
|
265
|
+
</FieldEdit>
|
|
266
|
+
</div>
|
|
267
|
+
);
|
|
268
|
+
}}
|
|
269
|
+
pos={{ x: 100, y: 100, w: 400, h: 200 }} title='Field Edit'>
|
|
270
|
+
</Modal>
|
|
271
|
+
</>
|
|
272
|
+
)
|
|
273
|
+
case 9:
|
|
274
|
+
return (
|
|
275
|
+
<>
|
|
276
|
+
<div className="div-on-menu">
|
|
277
|
+
Editable grid.
|
|
278
|
+
</div>
|
|
279
|
+
<div className="div-with-grid">
|
|
280
|
+
<GridFE getRows={GetFamily} getColumns={GetFamilyColumns} allowEdit={true}></GridFE>
|
|
281
|
+
</div>
|
|
282
|
+
</>
|
|
283
|
+
);
|
|
284
|
+
case 10:
|
|
285
|
+
return (
|
|
286
|
+
<>
|
|
287
|
+
<div className="div-on-menu">
|
|
288
|
+
Editable grid with card-based record view.
|
|
289
|
+
</div>
|
|
290
|
+
<div className="div-with-grid">
|
|
291
|
+
<GridCD getRows={GetFamily} getColumns={GetFamilyColumns} allowEdit={true}></GridCD>
|
|
292
|
+
</div>
|
|
293
|
+
</>
|
|
294
|
+
);
|
|
295
|
+
case 11:
|
|
296
|
+
return (
|
|
297
|
+
<>
|
|
298
|
+
{drawTest()}
|
|
299
|
+
</>
|
|
300
|
+
);
|
|
301
|
+
default:
|
|
302
|
+
return null;
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
306
|
+
return (
|
|
307
|
+
<div >
|
|
308
|
+
<select onChange={(e) => {
|
|
309
|
+
//console.log('this == ' + e);
|
|
310
|
+
setState({ menuItem: e.target.selectedIndex });
|
|
311
|
+
}}>
|
|
312
|
+
<option>0. None</option>
|
|
313
|
+
<option>1. React Grid</option>
|
|
314
|
+
<option>2. Overlay</option>
|
|
315
|
+
<option>3. Modal</option>
|
|
316
|
+
<option>4. Dropdown</option>
|
|
317
|
+
<option>5. Two Grids</option>
|
|
318
|
+
<option>6. GridDB</option>
|
|
319
|
+
<option>7. GridFL</option>
|
|
320
|
+
<option>8. Field Edit</option>
|
|
321
|
+
<option>9. GridFE</option>
|
|
322
|
+
<option>10. GridCD</option>
|
|
323
|
+
<option>11. TEST</option>
|
|
324
|
+
</select>
|
|
325
|
+
<div className="div-on-menu">
|
|
326
|
+
{getTestApp()}
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export default DebugApp;
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
export class TestData {
|
|
2
|
+
getFamily(e) {
|
|
3
|
+
e = e || { grid: {} };
|
|
4
|
+
|
|
5
|
+
const family = [
|
|
6
|
+
{ Id: 1, ParentId: [3, 4], Name: 'Mikle', SecondName: 'Razumtsev', Date: '26/01/1979', Comment: 'Good boy', Hometown: 'Voronezh', HometownId: 1 },
|
|
7
|
+
{ Id: 2, ParentId: [0], Name: 'Nataly', SecondName: 'Sche..', Date: '14/01/1999', Comment: 'Good girl', Hometown: 'Hanty-Mansiysk', HometownId: 12 },
|
|
8
|
+
{ Id: 3, ParentId: [11, 23], Name: 'Lyuda', SecondName: 'Razumtseva', Date: '03/07/1953', Comment: 'Mommy', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
9
|
+
{ Id: 4, ParentId: [5, 22], Name: 'Borya', SecondName: 'Razumtsev', Date: '14/06/1953', Comment: 'Papa', Hometown: 'Grafskaya', HometownId: 2 },
|
|
10
|
+
{ Id: 5, ParentId: [0], Name: 'Nina', SecondName: 'Razumtseva', Date: '17/06/1917', Comment: 'Babushka', Hometown: 'Ustyuzhna', HometownId: 9 },
|
|
11
|
+
{ Id: 6, ParentId: [3, 4], Name: 'Evgenia', SecondName: 'Batyreva', Date: '31/10/1974', Comment: 'Sister', Hometown: 'Voronezh', HometownId: 1 },
|
|
12
|
+
{ Id: 7, ParentId: [9, 10], Name: 'Ilia', SecondName: 'Razumtsev', Date: '16/09/1980', Comment: 'Brother 1', Hometown: 'Pskov', HometownId: 4 },
|
|
13
|
+
{ Id: 8, ParentId: [9, 10], Name: 'Mitka', SecondName: 'Razumtsev', Date: '04/07/1989', Comment: 'Brother 2', Hometown: 'Pskov', HometownId: 4 },
|
|
14
|
+
{ Id: 9, ParentId: [5, 22], Name: 'Kolya', SecondName: 'Razumtsev', Date: '02/11/1954', Comment: 'Dadya', Hometown: 'Grafskaya', HometownId: 2 },
|
|
15
|
+
{ Id: 10, ParentId: [11, 23], Name: 'Lara', SecondName: 'Razumtseva', Date: '31/01/1961', Comment: 'Tetya', Hometown: 'Elista', HometownId: 5 },
|
|
16
|
+
{ Id: 11, ParentId: [0], Name: 'Valya', SecondName: 'Mukhlynova', Date: '23/06/1933', Comment: 'Babushka', Hometown: 'Elista', HometownId: 5 },
|
|
17
|
+
{ Id: 12, ParentId: [6, 32], Name: 'Dashka', SecondName: 'Markelova', Date: '08/06/2000', Comment: 'Plemyannica 1', Hometown: 'Elista', HometownId: 5 },
|
|
18
|
+
{ Id: 13, ParentId: [6, 32], Name: 'Katka', SecondName: 'Markelova', Date: '27/05/2003', Comment: 'Plemyannica 2', Hometown: 'Elista', HometownId: 5 },
|
|
19
|
+
{ Id: 14, ParentId: [6, 31], Name: 'Tuyanka', SecondName: 'Batyreva', Date: '15/11/2010', Comment: 'Plemyannica 3', Hometown: 'Elista', HometownId: 5 },
|
|
20
|
+
{ Id: 15, ParentId: [0], Name: 'Shura', SecondName: 'Pelushskaya', Date: '22/04/1919', Comment: 'Dv. Babushka', Hometown: 'Ustyuzhna', HometownId: 9 },
|
|
21
|
+
{ Id: 16, ParentId: [15], Name: 'Ira', SecondName: 'Pelushskaya', Date: '11/06/1947', Comment: 'Dv. Tetya', Hometown: 'Pskov', HometownId: 4 },
|
|
22
|
+
{ Id: 17, ParentId: [11, 23], Name: 'Sveta', SecondName: 'Dolginova', Date: '10/11/1954', Comment: 'Tetya', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
23
|
+
{ Id: 18, ParentId: [11, 23], Name: 'Rita', SecondName: 'Dolginova', Date: '23/10/1956', Comment: 'Tetya', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
24
|
+
{ Id: 19, ParentId: [11, 23], Name: 'Nadya', SecondName: 'Shaula', Date: '11/11/1958', Comment: 'Tetya', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
25
|
+
{ Id: 20, ParentId: [11, 23], Name: 'Vitia', SecondName: 'Dolginov', Date: '11/11/1958', Comment: 'Dadya', Hometown: 'Novosibirsk', HometownId: 8 },
|
|
26
|
+
{ Id: 21, ParentId: [11, 23], Name: 'Tanya', SecondName: 'Dolginova', Date: '07/01/1963', Comment: 'Tetya', Hometown: 'Elista', HometownId: 5 },
|
|
27
|
+
{ Id: 22, ParentId: [0], Name: 'Misha', SecondName: 'Razumtsev', Date: '05/11/1918', Comment: 'Ded', Hometown: 'Grafskaya', HometownId: 2 },
|
|
28
|
+
{ Id: 23, ParentId: [0], Name: 'Zambo', SecondName: 'Dolginov', Date: '24/04/1926', Comment: 'Ded 2', Hometown: 'Elista', HometownId: 5 },
|
|
29
|
+
{ Id: 24, ParentId: [18, 34], Name: 'Alina', SecondName: 'Ushakova', Date: '??/??/????', Comment: 'Dv. Sister', Hometown: 'Elista', HometownId: 5 },
|
|
30
|
+
{ Id: 25, ParentId: [19, 33], Name: 'Igor', SecondName: 'Shaula', Date: '??/??/????', Comment: 'Dv. Brother', Hometown: 'Energodar', HometownId: 14 },
|
|
31
|
+
{ Id: 26, ParentId: [19, 33], Name: 'Dima', SecondName: 'Shaula', Date: '??/??/????', Comment: 'Dv. Brother', Hometown: 'Energodar', HometownId: 14 },
|
|
32
|
+
{ Id: 27, ParentId: [20, 35], Name: 'Olga', SecondName: 'Dolginova', Date: '??/??/????', Comment: 'Dv. Sister', Hometown: 'Elista', HometownId: 5 },
|
|
33
|
+
{ Id: 28, ParentId: [20, 35], Name: 'Venia', SecondName: 'Dolginov', Date: '??/??/????', Comment: 'Dv. Brother', Hometown: 'Elista', HometownId: 5 },
|
|
34
|
+
{ Id: 29, ParentId: [20, 36], Name: 'Oleg', SecondName: 'Dolginov', Date: '10/11/????', Comment: 'Dv. Brother', Hometown: 'Elista', HometownId: 5 },
|
|
35
|
+
{ Id: 30, ParentId: [0], Name: 'Yura', SecondName: 'Pelushskiy', Date: '??/??/1921', Comment: 'Dv. Ded', Hometown: 'Ustyuzhna', HometownId: 9 },
|
|
36
|
+
{ Id: 31, ParentId: [0], Name: 'Sanal', SecondName: 'Batyrev', Date: '11/06/????', Comment: 'Muzh Sestry 3', Hometown: 'Elista', HometownId: 5 },
|
|
37
|
+
{ Id: 32, ParentId: [0], Name: 'Dima', SecondName: 'Markelov', Date: '??/??/????', Comment: 'Muzh Sestry 2', Hometown: 'Elista', HometownId: 5 },
|
|
38
|
+
{ Id: 33, ParentId: [0], Name: 'Slava', SecondName: 'Shaula', Date: '??/??/????', Comment: 'Muzh Teti', Hometown: 'Energodar', HometownId: 14 },
|
|
39
|
+
{ Id: 34, ParentId: [0], Name: 'Sasha', SecondName: 'Ushakov', Date: '??/??/????', Comment: 'Muzh Teti', Hometown: 'Elista', HometownId: 5 },
|
|
40
|
+
{ Id: 35, ParentId: [0], Name: 'Toma', SecondName: '???', Date: '??/??/????', Comment: 'Mat Olgi i Veni', Hometown: 'Elista', HometownId: 5 },
|
|
41
|
+
{ Id: 36, ParentId: [0], Name: 'Ira', SecondName: '???', Date: '??/??/????', Comment: 'Mat Olega', Hometown: 'Elista', HometownId: 5 },
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
if (e.autocompleteColumn) {
|
|
45
|
+
e.grid._autocomplDict = {};
|
|
46
|
+
e.grid._autocomplCount = 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let rows = [];
|
|
50
|
+
|
|
51
|
+
for (let row of family) {
|
|
52
|
+
if (!this.passRow(e.grid, row, e.autocompleteColumn)) continue;
|
|
53
|
+
|
|
54
|
+
if (e.autocompleteColumn) {
|
|
55
|
+
e.grid._autocomplCount++;
|
|
56
|
+
if (e.grid._autocomplCount > 10) break;
|
|
57
|
+
|
|
58
|
+
let cellValue = row[e.autocompleteColumn.name];
|
|
59
|
+
e.grid._autocomplDict[String(cellValue).toLowerCase()] = 1;
|
|
60
|
+
|
|
61
|
+
rows.push(cellValue);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
rows.push(row);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!e.autocompleteColumn) {
|
|
69
|
+
e.grid.totalRows = rows.length;
|
|
70
|
+
|
|
71
|
+
if (e.grid.columns) {
|
|
72
|
+
let sortCol = null;
|
|
73
|
+
for (let col of e.grid.columns) {
|
|
74
|
+
if (col.asc || col.desc) {
|
|
75
|
+
sortCol = col;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (sortCol != null) {
|
|
81
|
+
rows.sort(function (a, b) { return a[sortCol.name] > b[sortCol.name] ? (sortCol.asc ? 1 : -1) : (sortCol.asc ? -1 : 1); });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (e.autocompleteColumn) {
|
|
87
|
+
rows.sort(function (a, b) { return a > b ? 1 : -1; });
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
rows = e.grid.pageSize > 0 && e.grid.pageNumber > 0 ? rows.slice((e.grid.pageNumber - 1) * e.grid.pageSize, e.grid.pageNumber * e.grid.pageSize) : rows;
|
|
91
|
+
|
|
92
|
+
e.grid.rows = rows;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return rows;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
GetFamilyColumns() {
|
|
99
|
+
return [
|
|
100
|
+
{ name: 'Id', sortable: true, filtrable: true },
|
|
101
|
+
{ name: 'Name', sortable: true, filtrable: true },
|
|
102
|
+
{ name: 'SecondName', sortable: true, filtrable: true },
|
|
103
|
+
{ name: 'Date', sortable: true, type: 'date' },
|
|
104
|
+
{ name: 'Comment', sortable: true, filtrable: true },
|
|
105
|
+
{
|
|
106
|
+
name: 'Hometown', sortable: true, filtrable: true, type: 'lookup', keyField: 'HometownId', refKeyField: 'Id', refNameField: 'City', getRows: (e) => {
|
|
107
|
+
return new Promise(function (resolve, reject) {
|
|
108
|
+
|
|
109
|
+
const rows = new TestData().getCity(e);
|
|
110
|
+
|
|
111
|
+
if (rows != null) {
|
|
112
|
+
resolve(rows);
|
|
113
|
+
} else {
|
|
114
|
+
reject(Error("Error getting rows"));
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
getCity(e) {
|
|
123
|
+
const cities = [
|
|
124
|
+
{ Id: 1, City: 'Voronezh', ParentId: [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23] },
|
|
125
|
+
{ Id: 2, City: 'Grafskaya', ParentId: [1, 3, 4, 5, 6, 7, 9, 10, 11, 15, 16, 17, 18, 19, 20, 21, 22, 23] },
|
|
126
|
+
{ Id: 3, City: 'Moskow', ParentId: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 23, 28, 29] },
|
|
127
|
+
{ Id: 4, City: 'Pskov', ParentId: [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 16, 30] },
|
|
128
|
+
{ Id: 5, City: 'Elista', ParentId: [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29] },
|
|
129
|
+
{ Id: 6, City: 'Pyatigorsk', ParentId: [1, 3, 4, 6, 12, 13, 14] },
|
|
130
|
+
{ Id: 7, City: 'Piter', ParentId: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 16] },
|
|
131
|
+
{ Id: 8, City: 'Novosibirsk', ParentId: [1, 3, 4, 11, 14, 17, 18, 19, 20, 23] },
|
|
132
|
+
{ Id: 9, City: 'Ustyuzhna', ParentId: [5, 15, 30] },
|
|
133
|
+
{ Id: 10, City: 'Army', ParentId: [1, 7, 8, 9, 20] },
|
|
134
|
+
{ Id: 11, City: 'Bali', ParentId: [2] },
|
|
135
|
+
{ Id: 12, City: 'Hanty-Mansiysk', ParentId: [2] },
|
|
136
|
+
{ Id: 13, City: 'Paris', ParentId: [21] },
|
|
137
|
+
{ Id: 14, City: 'Energodar', ParentId: [19, 25, 26] },
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
if (e.autocompleteColumn) {
|
|
141
|
+
e.grid._autocomplDict = {};
|
|
142
|
+
e.grid._autocomplCount = 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let rows = [];
|
|
146
|
+
|
|
147
|
+
for (let row of cities) {
|
|
148
|
+
if (!this.passRow(e.grid, row, e.autocompleteColumn)) continue;
|
|
149
|
+
|
|
150
|
+
if (e.filters && e.filters.length) {
|
|
151
|
+
let filter = e.filters[0];
|
|
152
|
+
filter = filter.filter ? filter.filter : filter;
|
|
153
|
+
if (!row['ParentId'] || row['ParentId'].indexOf(+filter) < 0) continue;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (e.autocompleteColumn) {
|
|
157
|
+
e.grid._autocomplCount++;
|
|
158
|
+
if (e.grid._autocomplCount > 10) break;
|
|
159
|
+
|
|
160
|
+
let cellValue = row[e.autocompleteColumn.name];
|
|
161
|
+
e.grid._autocomplDict[String(cellValue).toLowerCase()] = 1;
|
|
162
|
+
|
|
163
|
+
rows.push(cellValue);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
rows.push(row);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (!e.autocompleteColumn && e.grid) {
|
|
171
|
+
e.grid.totalRows = rows.length;
|
|
172
|
+
|
|
173
|
+
if (e.grid.columns) {
|
|
174
|
+
let sortCol = null;
|
|
175
|
+
for (let col of e.grid.columns) {
|
|
176
|
+
if (col.asc || col.desc) {
|
|
177
|
+
sortCol = col;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (sortCol != null) {
|
|
183
|
+
rows.sort(function (a, b) { return a[sortCol.name] > b[sortCol.name] ? (sortCol.asc ? 1 : -1) : (sortCol.asc ? -1 : 1); });
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (e.autocompleteColumn) {
|
|
189
|
+
rows.sort(function (a, b) { return a > b ? 1 : -1; });
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
rows = e.grid.pageSize > 0 && e.grid.pageNumber > 0 ? rows.slice((e.grid.pageNumber - 1) * e.grid.pageSize, e.grid.pageNumber * e.grid.pageSize) : rows;
|
|
193
|
+
|
|
194
|
+
e.grid.rows = rows;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return rows;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
GetCityColumns() {
|
|
201
|
+
return [{ name: 'Id', sortable: true }, { name: 'City', sortable: true, filtrable: true }]
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
passRow(grid, row, autocompleteColumn) {
|
|
205
|
+
if (!grid || !grid.columns) return true;
|
|
206
|
+
|
|
207
|
+
for (let col of grid.columns) {
|
|
208
|
+
if (!col.filtrable || (col.filter == null || col.filter == '') && !autocompleteColumn) continue;
|
|
209
|
+
|
|
210
|
+
const cellValue = String(row[col.name]).toLowerCase();
|
|
211
|
+
if (cellValue == '') return false;
|
|
212
|
+
|
|
213
|
+
const filter = col.filter == null || col.filter == '' ? '' : col.filter.toLowerCase();
|
|
214
|
+
|
|
215
|
+
if (filter != '') {
|
|
216
|
+
if (autocompleteColumn) {
|
|
217
|
+
if (autocompleteColumn == col && cellValue.indexOf(filter) != 0 || autocompleteColumn != col && cellValue != filter) return false;
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
if (cellValue != filter) return false;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (autocompleteColumn && grid._autocomplDict[cellValue]) return false;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
GetCities = function (e) {
|
|
232
|
+
return new Promise(function (resolve, reject) {
|
|
233
|
+
|
|
234
|
+
const rows = new TestData().getCity(e);
|
|
235
|
+
|
|
236
|
+
if (rows != null) {
|
|
237
|
+
resolve(rows);
|
|
238
|
+
} else {
|
|
239
|
+
reject(Error("Error getting rows"));
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class DefaultGridTheme {
|
|
2
|
+
|
|
3
|
+
constructor() {
|
|
4
|
+
this.pagerButtonsClass = 'grid-pager-button';
|
|
5
|
+
this.toolbarClass = '';
|
|
6
|
+
this.toolbarButtonsClass = 'grid-toolbar-button';
|
|
7
|
+
this.pocketButtonsClass = 'grid-pocket-button';
|
|
8
|
+
|
|
9
|
+
this.pagerClass = 'mb-1 grid-pager-default';
|
|
10
|
+
|
|
11
|
+
this.gridClass = '';
|
|
12
|
+
//this.headerDivClass = 'grid-header-div-default';
|
|
13
|
+
this.headerDivClass = ' ';
|
|
14
|
+
this.selectedRowClass = 'table-active';
|
|
15
|
+
this.inputClass = 'input-default-class';
|
|
16
|
+
this.inputClassLG = 'input-default-class-lg';
|
|
17
|
+
this.selectClass = 'select-default-class';
|
|
18
|
+
|
|
19
|
+
this.tabControlButtonClass = 'graph-tabcontrol-button';
|
|
20
|
+
|
|
21
|
+
this.menuClass = '';
|
|
22
|
+
this.menuItemClass = '';
|
|
23
|
+
this.dropdownWndClass = 'none';
|
|
24
|
+
|
|
25
|
+
this.filterButtonClass = 'graph-filter-button';
|
|
26
|
+
this.clearButtonClass = '';
|
|
27
|
+
|
|
28
|
+
this.modalBodyClass = 'modal-window-body';
|
|
29
|
+
this.modalHeaderClass = 'modal-window-header';
|
|
30
|
+
this.modalFooterClass = 'modal-window-footer';
|
|
31
|
+
this.modalFooterButtonClass = 'modal-window-footer-button'
|
|
32
|
+
this.modalTitleClass = 'modal-window-header-title';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// -------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
36
|
+
}
|