-
Notifications
You must be signed in to change notification settings - Fork 43
/
GridRoot.js
817 lines (732 loc) · 27.2 KB
/
GridRoot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
import React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import {each, extend, extendOwn, isArray, isFunction, isEqual, isObject, throttle} from 'underscore';
import {fromJS} from 'immutable';
import PropTypes from 'prop-types';
import * as UTIL from '../_inc/utils';
import GridHeader from './GridHeader';
import GridBody from './GridBody';
import GridPage from './GridPage';
import GridScroll from './GridScroll';
//~~~~~
const defaultOptions = {
frozenColumnIndex: 0,
frozenRowIndex: 0,
showLineNumber: false,
showRowSelector: false,
multipleSelect: true,
columnMinWidth: 100,
lineNumberColumnWidth: 40,
rowSelectorColumnWidth: 28,
sortable: false,
remoteSort: false,
asidePanelWidth: 0,
header: {
display: true,
align: false,
columnHeight: 24,
columnPadding: 3,
columnBorderWidth: 1,
selector: true
},
body: {
align: false,
columnHeight: 24,
columnPadding: 3,
columnBorderWidth: 1,
grouping: false,
mergeCells: false
},
page: {
buttonsContainerWidth: 150,
buttons: [
{className: 'datagridIcon-first', onClick: 'PAGE_FIRST'},
{className: 'datagridIcon-prev', onClick: 'PAGE_PREV'},
{className: 'datagridIcon-back', onClick: 'PAGE_BACK'},
{className: 'datagridIcon-play', onClick: 'PAGE_PLAY'},
{className: 'datagridIcon-next', onClick: 'PAGE_NEXT'},
{className: 'datagridIcon-last', onClick: 'PAGE_LAST'}
],
buttonHeight: 16,
height: 19
},
scroller: {
size: 14,
arrowSize: 14,
barMinSize: 12,
padding: 3,
useVerticalScroll: true
},
columnKeys: {
selected: '__selected__',
modified: '__modified__',
deleted: '__deleted__',
disableSelection: '__disable_selection__'
},
tree: {
use: false,
hashDigit: 8,
indentWidth: 10,
arrowWidth: 15,
iconWidth: 18,
icons: {
openedArrow: '▾',
collapsedArrow: '▸',
groupIcon: '⊚',
collapsedGroupIcon: '⊚',
itemIcon: '⊙'
},
columnKeys: {
parentKey: "pid",
selfKey: "id",
collapse: "collapse",
hidden: "hidden",
parentHash: "__hp__",
selfHash: "__hs__",
children: "__children__",
depth: "__depth__",
}
},
footSum: false
};
const propsToState = function (props, state) {
let dividedObj;
// state 계산영역 시작
state.headerTable = UTIL.makeHeaderTable(props.columns, state.options);
state.bodyRowTable = UTIL.makeBodyRowTable(props.columns, state.options);
state.bodyRowMap = UTIL.makeBodyRowMap(state.bodyRowTable, state.options);
dividedObj = UTIL.divideTableByFrozenColumnIndex(state.headerTable, state.options.frozenColumnIndex, state.options);
state.asideHeaderData = dividedObj.asideData;
state.asideColGroup = dividedObj.asideColGroup; // asideColGroup은 header, bodyRow 에서 공통으로 사용 한번만 구하면 그만이지만 편의상 header에서 처리하기로 한다.
state.leftHeaderData = dividedObj.leftData;
state.headerData = dividedObj.rightData;
state.styles.asidePanelWidth = dividedObj.asidePanelWidth;
dividedObj = UTIL.divideTableByFrozenColumnIndex(state.bodyRowTable, state.options.frozenColumnIndex, state.options);
state.asideBodyRowData = dividedObj.asideData;
state.leftBodyRowData = dividedObj.leftData;
state.bodyRowData = dividedObj.rightData;
// 한줄의 높이 계산 (한줄이 여러줄로 구성되었다면 높이를 늘려야 하니까);
state.styles.bodyTrHeight = state.bodyRowTable.rows.length * state.options.body.columnHeight;
state.colGroupMap = {};
state.headerTable.rows.forEach((row, r) => {
row.cols.forEach((col, c) => {
state.colGroupMap[col.colIndex] = extend({}, col);
});
});
state.colGroup = [];
each(state.colGroupMap, (v, k) => {
state.colGroup.push(v);
});
state.leftHeaderColGroup = state.colGroup.slice(0, state.options.frozenColumnIndex);
state.headerColGroup = state.colGroup.slice(state.options.frozenColumnIndex);
// footSum
state.footSumColumns = [];
state.footSumTable = {};
if (isArray(state.options.footSum)) {
state.footSumColumns = state.options.footSum;
state.footSumTable = UTIL.makeFootSumTable(state.footSumColumns, state.colGroup, state.options);
dividedObj = UTIL.divideTableByFrozenColumnIndex(state.footSumTable, state.options.frozenColumnIndex, state.options);
state.leftFootSumData = dividedObj.leftData;
state.footSumData = dividedObj.rightData;
}
// grouping info
if (state.options.body.grouping) {
if ("by" in state.options.body.grouping && "columns" in state.options.body.grouping) {
state.bodyGrouping = {
by: state.options.body.grouping.by,
columns: state.options.body.grouping.columns
};
state.bodyGroupingTable = UTIL.makeBodyGroupingTable(state.bodyGrouping.columns, state.colGroup, state.options);
state.sortInfo = (() => {
let sortInfo = {};
for (let k = 0, kl = state.bodyGrouping.by.length; k < kl; k++) {
sortInfo[state.bodyGrouping.by[k]] = {
orderBy: "asc",
seq: k,
fixed: true
};
for (let c = 0, cl = colGroup.length; c < cl; c++) {
if (state.colGroup[c].key === state.bodyGrouping.by[k]) {
state.colGroup[c].sort = "asc";
state.colGroup[c].sortFixed = true;
}
}
}
return sortInfo;
})();
dividedObj = UTIL.divideTableByFrozenColumnIndex(state.bodyGroupingTable, state.options.frozenColumnIndex, state.options);
state.asideBodyGroupingData = dividedObj.asideData;
state.leftBodyGroupingData = dividedObj.leftData;
state.bodyGroupingData = dividedObj.rightData;
state.bodyGroupingMap = UTIL.makeBodyRowMap(state.bodyGroupingTable, state.options);
} else {
state.options.body.grouping = false;
}
}
return state;
};
class GridRoot extends React.Component {
constructor(props) {
super(props);
this.componentRefs = {};
this.data = {
sColIndex: -1,
eColIndex: -1
};
// 내부연산용 데이터 저장소
this.state = {
mounted: false,
scrollLeft: null,
scrollTop: null,
dragging: false, // 사용자가 드래깅 중인 경우 (style.userSelect=none 처리)
isInlineEditing: false,
focusedColumn: {},
selectedColumn: {},
inlineEditingColumn: {},
colGroup: [],
colGroupMap: {},
asideColGroup: [],
leftHeaderColGroup: [],
headerColGroup: [],
bodyGrouping: [],
headerTable: {},
asideHeaderData: {},
leftHeaderData: {},
headerData: {},
bodyRowTable: {},
asideBodyRowData: {},
leftBodyRowData: {},
bodyRowData: {},
bodyRowMap: {},
bodyGroupingTable: {},
asideBodyGroupingData: {},
leftBodyGroupingData: {},
bodyGroupingData: {},
bodyGroupingMap: {},
footSumColumns: [],
footSumTable: {}, // footSum의 출력레이아웃
leftFootSumData: {}, // frozenColumnIndex 를 기준으로 나누어진 출력 레이아웃 왼쪽
footSumData: {}, // frozenColumnIndex 를 기준으로 나누어진 출력 레이아웃 오른쪽
styles: {
calculatedHeight: null,
// 줄번호 + 줄셀렉터의 너비
asidePanelWidth: null,
// 틀고정된 컬럼들의 너비
frozenPanelWidth: null,
// 한줄의 높이
bodyTrHeight: null,
// 컨테이너의 크기
elWidth: null,
elHeight: null,
CTInnerWidth: null,
CTInnerHeight: null,
rightPanelWidth: null,
// 헤더의 높이
headerHeight: null,
// 틀고정된 로우들의 높이
frozenRowHeight: null,
// 풋섬의 높이
footSumHeight: null,
// 페이징 영역의 높이
pageHeight: null,
// scrollTack 의 크기 (너비, 높이)
verticalScrollerWidth: null,
horizontalScrollerHeight: null,
bodyHeight: null,
scrollContentContainerHeight: null,
scrollContentHeight: null,
scrollContentContainerWidth: null,
scrollContentWidth: null
},
options: (() => {
let options = extend({}, defaultOptions);
each(props.options, function (v, k) {
options[k] = (isObject(v)) ? extendOwn(options[k], v) : v;
});
return options;
})()
};
this.state = propsToState(props, extend({}, this.state));
// state 계산영역 끝
this.props.init(props, this.state.options);
// 이벤트 멤버에 바인딩
this.onMouseDownScrollBar = this.onMouseDownScrollBar.bind(this);
this.onClickScrollTrack = this.onClickScrollTrack.bind(this);
this.onClickScrollArrow = this.onClickScrollArrow.bind(this);
this.onResizeColumnResizer = this.onResizeColumnResizer.bind(this);
this.onUpdateSelectedCells = this.onUpdateSelectedCells.bind(this);
this.onClickPageButton = this.onClickPageButton.bind(this);
this.refCallback = this.refCallback.bind(this);
}
componentDidMount() {
this.gridRootNode = ReactDOM.findDOMNode(this.refs.gridRoot);
this.throttled_updateDimensions = throttle(this.updateDimensions.bind(this), 100);
window.addEventListener("resize", this.throttled_updateDimensions);
this.setState({
mounted: true,
//styles: styles
});
}
componentWillUnmount() {
window.removeEventListener("resize", this.throttled_updateDimensions);
}
// 변경된 props를 받게 되면
componentWillReceiveProps(nextProps) {
// 데이터 체인지
if (this.props.data !== nextProps.data) {
this.props.setData(nextProps.data, this.state.options);
}
if (this.props.options !== nextProps.options || this.props.columns !== nextProps.columns) {
this.data._headerColGroup = undefined;
this.data.sColIndex = -1;
this.data.eColIndex = -1;
let newState = propsToState(nextProps, extend({}, this.state, {scrollLeft: 0, scrollTop: 0}));
newState.styles = UTIL.calculateDimensions(this.gridRootNode, {list: this.props.store_list}, newState).styles;
this.setState(newState);
}
}
shouldComponentUpdate(nextProps, nextState) {
if (this.props.data !== nextProps.data) {
return false;
}
if (
this.props.store_list !== nextProps.store_list ||
this.props.store_deletedList !== nextProps.store_deletedList ||
this.props.store_page !== nextProps.store_page ||
this.props.store_sortInfo !== nextProps.store_sortInfo
) {
// redux store state가 변경되면 렌더를 바로 하지 말고 this.state.styles 변경하여 state에 의해 랜더링 되도록 함. (이중으로 랜더링 하기 싫음)
this.setState({
styles: UTIL.calculateDimensions(this.gridRootNode, {list: nextProps.store_list}, this.state).styles
});
return false;
}
return true;
}
componentWillUpdate(nextProps) {
// console.log(this.state.sColIndex);
// shouldComponentUpdate에더 랜더를 방지 하거나. willUpdate에서 this.state.styles값 강제 변경 테스트.
}
// change props and render
componentDidUpdate(prevProps, prevState) {
if (prevProps.height != this.props.height) {
this.updateDimensions();
}
}
/**
* 사용자 함수
*/
updateDimensions() {
let {styles} = UTIL.calculateDimensions(this.gridRootNode, {list: this.props.store_list}, this.state);
let {scrollLeft, scrollTop} = UTIL.getScrollPosition(this.state.scrollLeft, this.state.scrollTop, {
scrollWidth: styles.scrollContentWidth,
scrollHeight: styles.scrollContentHeight,
clientWidth: styles.scrollContentContainerWidth,
clientHeight: styles.scrollContentContainerHeight
});
this.setState({
scrollLeft: scrollLeft,
scrollTop: scrollTop,
styles: styles
});
}
handleWheel(e) {
let delta = {x: 0, y: 0};
if (e.detail) {
delta.y = e.detail * 10;
}
else {
if (typeof e.deltaY === "undefined") {
delta.y = -e.wheelDelta;
delta.x = 0;
} else {
delta.y = e.deltaY;
delta.x = e.deltaX;
}
}
let {scrollLeft, scrollTop, endScroll} = UTIL.getScrollPosition(this.state.scrollLeft - delta.x, this.state.scrollTop - delta.y, {
scrollWidth: this.state.styles.scrollContentWidth,
scrollHeight: this.state.styles.scrollContentHeight,
clientWidth: this.state.styles.scrollContentContainerWidth,
clientHeight: this.state.styles.scrollContentContainerHeight
});
this.setState({
scrollLeft: scrollLeft,
scrollTop: scrollTop
});
if (!endScroll) {
e.preventDefault();
e.stopPropagation();
}
}
onMouseDownScrollBar(e, barName) {
e.preventDefault();
const styles = this.state.styles;
const currScrollBarLeft = -this.state.scrollLeft * (styles.horizontalScrollerWidth - styles.horizontalScrollBarWidth) / (styles.scrollContentWidth - styles.scrollContentContainerWidth);
const currScrollBarTop = -this.state.scrollTop * (styles.verticalScrollerHeight - styles.verticalScrollBarHeight) / (styles.scrollContentHeight - styles.scrollContentContainerHeight);
this.data[barName + '-scroll-bar'] = {
startMousePosition: UTIL.getMousePosition(e)
};
const onMouseMove = (ee) => {
if (!this.state.dragging) this.setState({dragging: true});
const {x, y} = UTIL.getMousePosition(ee);
const {startMousePosition} = this.data[barName + '-scroll-bar'];
const processor = {
vertical: () => {
let {scrollLeft, scrollTop} = UTIL.getScrollPositionByScrollBar(currScrollBarLeft, currScrollBarTop + (y - startMousePosition.y), styles);
this.setState({
scrollLeft: scrollLeft,
scrollTop: scrollTop
});
},
horizontal: () => {
let {scrollLeft, scrollTop} = UTIL.getScrollPositionByScrollBar(currScrollBarLeft + (x - startMousePosition.x), currScrollBarTop, styles);
this.setState({
scrollLeft: scrollLeft,
scrollTop: scrollTop
});
}
};
if (barName in processor) processor[barName]();
};
const offEvent = (e) => {
e.preventDefault();
this.setState({dragging: false});
this.data[barName + '-scroll-bar'] = null;
// console.log("offEvent");
document.removeEventListener('mousemove', onMouseMove);
document.removeEventListener('mouseup', offEvent);
document.removeEventListener('mouseleave', offEvent);
};
document.addEventListener('mousemove', onMouseMove);
document.addEventListener('mouseup', offEvent);
document.addEventListener('mouseleave', offEvent);
}
onClickScrollTrack(e, barName) {
const styles = this.state.styles;
const currScrollBarLeft = -this.state.scrollLeft * (styles.horizontalScrollerWidth - styles.horizontalScrollBarWidth) / (styles.scrollContentWidth - styles.scrollContentContainerWidth);
const currScrollBarTop = -this.state.scrollTop * (styles.verticalScrollerHeight - styles.verticalScrollBarHeight) / (styles.scrollContentHeight - styles.scrollContentContainerHeight);
const {x, y} = UTIL.getMousePosition(e);
const processor = {
vertical: () => {
let {scrollLeft, scrollTop} = UTIL.getScrollPositionByScrollBar(currScrollBarLeft, y - this.refs.gridRoot.offsetTop - (styles.verticalScrollBarHeight / 2), styles);
this.setState({
scrollLeft: scrollLeft,
scrollTop: scrollTop
});
},
horizontal: () => {
let {scrollLeft, scrollTop} = UTIL.getScrollPositionByScrollBar(x - this.refs.gridRoot.offsetLeft - styles.pageButtonsContainerWidth - (styles.horizontalScrollBarWidth / 2), currScrollBarTop, styles);
this.setState({
scrollLeft: scrollLeft,
scrollTop: scrollTop
});
}
};
if (barName in processor) processor[barName]();
}
onClickScrollArrow(e, direction) {
const styles = this.state.styles;
const processor = {
up: () => {
let scrollAmount = styles.scrollContentContainerHeight;
this.setState({
scrollTop: (this.state.scrollTop + scrollAmount < 0) ? this.state.scrollTop + scrollAmount : 0
});
},
down: () => {
let scrollAmount = styles.scrollContentContainerHeight;
this.setState({
scrollTop: (styles.scrollContentContainerHeight < styles.scrollContentHeight + (this.state.scrollTop - scrollAmount)) ? this.state.scrollTop - scrollAmount : styles.scrollContentContainerHeight - styles.scrollContentHeight
});
},
left: () => {
let scrollAmount = styles.scrollContentContainerWidth;
this.setState({
scrollLeft: (this.state.scrollLeft + scrollAmount < 0) ? this.state.scrollLeft + scrollAmount : 0
});
},
right: () => {
let scrollAmount = styles.scrollContentContainerWidth;
this.setState({
scrollLeft: (styles.scrollContentContainerWidth < styles.scrollContentWidth + (this.state.scrollLeft - scrollAmount)) ? this.state.scrollLeft - scrollAmount : styles.scrollContentContainerWidth - styles.scrollContentWidth
});
}
};
if (direction in processor) processor[direction]();
}
onResizeColumnResizer(e, col, newWidth) {
let colGroup = fromJS(this.state.colGroup).toJS();
colGroup[col.colIndex]._width = colGroup[col.colIndex].width = newWidth;
let leftHeaderColGroup = colGroup.slice(0, this.state.options.frozenColumnIndex);
let headerColGroup = colGroup.slice(this.state.options.frozenColumnIndex);
let {styles} = UTIL.calculateDimensions(this.gridRootNode, {list: this.props.store_list}, extend({}, this.state, {
colGroup: colGroup,
leftHeaderColGroup: leftHeaderColGroup,
headerColGroup: headerColGroup
}));
this.data._headerColGroup = undefined;
this.setState({
colGroup: colGroup,
leftHeaderColGroup: leftHeaderColGroup,
headerColGroup: headerColGroup,
styles: styles
});
}
onUpdateSelectedCells() {
}
onClickPageButton(e, onClick) {
const styles = this.state.styles;
const processor = {
'PAGE_FIRST': () => {
this.setState({
scrollTop: 0
});
},
'PAGE_PREV': () => {
},
'PAGE_BACK': () => {
},
'PAGE_PLAY': () => {
},
'PAGE_NEXT': () => {
},
'PAGE_LAST': () => {
this.setState({
scrollTop: styles.scrollContentContainerHeight - styles.scrollContentHeight
});
}
};
if (isFunction(onClick)) {
}
else if (typeof onClick === 'string' && onClick in processor) {
processor[onClick]();
}
}
refCallback(_key, el) {
// 하위 컴포넌트에서 전달해주는 ref를 수집 / 갱신
this.componentRefs[_key] = el;
}
render() {
const styles = this.state.styles;
const options = this.state.options;
const mounted = this.state.mounted;
const headerColGroup = this.state.headerColGroup;
let gridRootStyle = Object.assign({height: this.props.height}, this.props.style);
if (styles.calculatedHeight !== null) {
gridRootStyle.height = styles.calculatedHeight;
}
if (this.state.dragging) { // 드래깅 중이므로 내부 요소 text select 금지
gridRootStyle["userSelect"] = "none";
}
let _scrollLeft = Math.abs(this.state.scrollLeft);
let bodyPanelWidth = styles.CTInnerWidth - styles.asidePanelWidth - styles.frozenPanelWidth - styles.rightPanelWidth;
let sColIndex = 0, eColIndex = headerColGroup.length;
let _headerColGroup = headerColGroup;
let _bodyRowData = this.state.bodyRowData;
let _bodyGroupingData = this.state.bodyGroupingData;
// 프린트 컬럼 시작점과 끝점 연산
if (mounted) {
headerColGroup.forEach((col, ci) => {
if (col._sx <= _scrollLeft && col._ex >= _scrollLeft) {
sColIndex = ci;
}
if (col._sx <= _scrollLeft + bodyPanelWidth && col._ex >= _scrollLeft + bodyPanelWidth) {
eColIndex = ci;
return false;
}
});
_headerColGroup = headerColGroup.slice(sColIndex, eColIndex + 1);
if (typeof this.data._headerColGroup === "undefined" || !isEqual(this.data._headerColGroup, _headerColGroup)) {
this.data.sColIndex = sColIndex;
this.data.eColIndex = eColIndex;
this.data._headerColGroup = _headerColGroup;
_bodyRowData = this.data._bodyRowData = UTIL.getTableByStartEndColumnIndex(this.state.bodyRowData, sColIndex, eColIndex + 1);
_bodyGroupingData = this.data._bodyGroupingData = UTIL.getTableByStartEndColumnIndex(this.state.bodyGroupingData, sColIndex, eColIndex + 1);
} else {
_bodyRowData = this.data._bodyRowData;
_bodyGroupingData = this.data._bodyGroupingData;
}
}
return (
<div ref="gridRoot"
className={classNames(this.props.gridCSS.axDatagrid)}
onWheel={e => {
this.handleWheel(e);
}}
style={gridRootStyle}>
<div className={classNames(this.props.gridCSS.clipBoard)}>
<textarea ref="gridClipboard"></textarea>
</div>
<GridHeader
gridCSS={this.props.gridCSS}
refCallback={this.refCallback}
onResizeColumnResizer={this.onResizeColumnResizer}
mounted={mounted}
optionsHeader={options.header}
styles={styles}
frozenColumnIndex={options.frozenColumnIndex}
colGroup={this.state.colGroup}
asideColGroup={this.state.asideColGroup}
leftHeaderColGroup={this.state.leftHeaderColGroup}
headerColGroup={this.state.headerColGroup}
asideHeaderData={this.state.asideHeaderData}
leftHeaderData={this.state.leftHeaderData}
headerData={this.state.headerData}
scrollLeft={this.state.scrollLeft}
/>
<GridBody
gridCSS={this.props.gridCSS}
refCallback={this.refCallback}
onUpdateSelectedCells={this.onUpdateSelectedCells}
mounted={mounted}
options={options}
styles={styles}
CTInnerWidth={styles.CTInnerWidth}
CTInnerHeight={styles.CTInnerHeight}
frozenColumnIndex={options.frozenColumnIndex}
colGroup={this.state.colGroup}
asideColGroup={this.state.asideColGroup}
leftHeaderColGroup={this.state.leftHeaderColGroup}
headerColGroup={_headerColGroup}
bodyTable={this.state.bodyRowTable}
asideBodyRowData={this.state.asideBodyRowData}
asideBodyGroupingData={this.state.asideBodyGroupingData}
leftBodyRowData={this.state.leftBodyRowData}
leftBodyGroupingData={this.state.leftBodyGroupingData}
bodyRowData={_bodyRowData}
bodyGroupingData={_bodyGroupingData}
list={this.props.store_list}
scrollLeft={this.state.scrollLeft}
scrollTop={this.state.scrollTop}
/>
<GridPage
gridCSS={this.props.gridCSS}
refCallback={this.refCallback}
onClickPageButton={this.onClickPageButton}
mounted={mounted}
styles={styles}
pageButtonsContainerWidth={styles.pageButtonsContainerWidth}
pageButtons={options.page.buttons}
pageButtonHeight={options.page.buttonHeight}
list={this.props.store_list}
scrollLeft={this.state.scrollLeft}
scrollTop={this.state.scrollTop}
/>
<GridScroll
gridCSS={this.props.gridCSS}
refCallback={this.refCallback}
onMouseDownScrollBar={this.onMouseDownScrollBar}
onClickScrollTrack={this.onClickScrollTrack}
onClickScrollArrow={this.onClickScrollArrow}
mounted={mounted}
optionsScroller={options.scroller}
bodyHeight={styles.bodyHeight}
pageHeight={styles.pageHeight}
verticalScrollerWidth={styles.verticalScrollerWidth}
verticalScrollerHeight={styles.verticalScrollerHeight}
horizontalScrollerWidth={styles.horizontalScrollerWidth}
horizontalScrollerHeight={styles.horizontalScrollerHeight}
verticalScrollBarHeight={styles.verticalScrollBarHeight}
horizontalScrollBarWidth={styles.horizontalScrollBarWidth}
scrollerArrowSize={styles.scrollerArrowSize}
scrollerPadding={styles.scrollerPadding}
scrollBarLeft={-this.state.scrollLeft * (styles.horizontalScrollerWidth - styles.horizontalScrollBarWidth) / (styles.scrollContentWidth - styles.scrollContentContainerWidth)}
scrollBarTop={-this.state.scrollTop * (styles.verticalScrollerHeight - styles.verticalScrollBarHeight) / (styles.scrollContentHeight - styles.scrollContentContainerHeight)}
/>
<div ref="gridVerticalResizer"></div>
<div ref="gridHorizontalResizer"></div>
</div>
);
}
}
GridRoot.propTypes = {
height: PropTypes.string,
columns: PropTypes.array,
data: PropTypes.oneOfType([
PropTypes.array,
PropTypes.object
]),
options: PropTypes.shape({
frozenColumnIndex: PropTypes.number,
frozenRowIndex: PropTypes.number,
showLineNumber: PropTypes.bool,
showRowSelector: PropTypes.bool,
multipleSelect: PropTypes.bool,
columnMinWidth: PropTypes.number,
lineNumberColumnWidth: PropTypes.number,
rowSelectorColumnWidth: PropTypes.number,
sortable: PropTypes.bool,
remoteSort: PropTypes.bool,
asidePanelWidth: PropTypes.number,
header: PropTypes.shape({
display: PropTypes.bool,
align: PropTypes.string,
columnHeight: PropTypes.number,
columnPadding: PropTypes.number,
columnBorderWidth: PropTypes.number,
selector: PropTypes.bool
}),
body: PropTypes.shape({
align: PropTypes.bool,
columnHeight: PropTypes.number,
columnPadding: PropTypes.number,
columnBorderWidth: PropTypes.number,
grouping: PropTypes.bool,
mergeCells: PropTypes.bool
}),
page: PropTypes.shape({
height: PropTypes.number,
display: PropTypes.bool,
statusDisplay: PropTypes.bool,
navigationItemCount: PropTypes.number
}),
scroller: PropTypes.shape({
size: PropTypes.number,
barMinSize: PropTypes.number,
useVerticalScroll: PropTypes.bool
}),
columnKeys: PropTypes.shape({
selected: PropTypes.string,
modified: PropTypes.string,
deleted: PropTypes.string,
disableSelection: PropTypes.string
}),
tree: PropTypes.shape({
use: PropTypes.bool,
hashDigit: PropTypes.number,
indentWidth: PropTypes.number,
arrowWidth: PropTypes.number,
iconWidth: PropTypes.number,
icons: PropTypes.shape({
openedArrow: PropTypes.string,
collapsedArrow: PropTypes.string,
groupIcon: PropTypes.string,
collapsedGroupIcon: PropTypes.string,
itemIcon: PropTypes.string
}),
columnKeys: PropTypes.shape({
parentKey: PropTypes.string,
selfKey: PropTypes.string,
collapse: PropTypes.string,
hidden: PropTypes.string,
parentHash: PropTypes.string,
selfHash: PropTypes.string,
children: PropTypes.string,
depth: PropTypes.string,
})
})
}),
footSum: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.func
])
};
GridRoot.defaultProps = {
height: "300px",
columns: [],
data: [],
options: {}
};
export default GridRoot;