@azrico/reactgrid 1.1.7 → 1.1.9
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/dist/src/example.js +42 -35
- package/dist/src/index.js +2 -2
- package/dist/src/views/DataGrid.js +49 -27
- package/package.json +1 -1
- package/src/example.tsx +51 -43
- package/src/index.tsx +2 -2
- package/src/views/DataGrid.tsx +54 -30
package/dist/src/example.js
CHANGED
|
@@ -51,25 +51,26 @@ function getData() {
|
|
|
51
51
|
name: 'user-' + index,
|
|
52
52
|
age: 20
|
|
53
53
|
});
|
|
54
|
-
if (index % 5 == 0) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
54
|
+
//if (index % 5 == 0) {
|
|
55
|
+
// const sub_selfid = 's' + index;
|
|
56
|
+
// fd.push({
|
|
57
|
+
// __table_id: sub_selfid,
|
|
58
|
+
// __parent__table_id: String(index),
|
|
59
|
+
// name: 'sub-' + index,
|
|
60
|
+
// age: 20,
|
|
61
|
+
// });
|
|
62
|
+
// if (index % 2 == 0) {
|
|
63
|
+
// const sub2_selfid = 'ss' + index;
|
|
64
|
+
// fd.push({
|
|
65
|
+
// __table_id: sub2_selfid,
|
|
66
|
+
// __parent__table_id: sub_selfid,
|
|
67
|
+
// name: 'sub2-' + index,
|
|
68
|
+
// age: 20,
|
|
69
|
+
// });
|
|
70
|
+
// }
|
|
71
|
+
//}
|
|
72
72
|
}
|
|
73
|
+
|
|
73
74
|
return fd;
|
|
74
75
|
}
|
|
75
76
|
function ExampleGrid() {
|
|
@@ -83,34 +84,40 @@ function ExampleGrid() {
|
|
|
83
84
|
}, 1000);
|
|
84
85
|
});
|
|
85
86
|
}, [ds_reset]);
|
|
87
|
+
const onRowDoubleClick = _react.default.useCallback((index, rowdata) => {
|
|
88
|
+
console.log((rowdata === null || rowdata === void 0 ? void 0 : rowdata.data) || rowdata);
|
|
89
|
+
}, []);
|
|
90
|
+
const onRowClick = _react.default.useCallback((index, rowdata) => {
|
|
91
|
+
//console.log(rowdata?.data || rowdata);
|
|
92
|
+
}, []);
|
|
86
93
|
function rst_ds() {
|
|
87
94
|
//console.log('rst_ds');
|
|
88
95
|
set_ds_reset(s => s + 1);
|
|
89
96
|
}
|
|
90
|
-
return _react.default.createElement(
|
|
91
|
-
onClick: rst_ds
|
|
92
|
-
}, "RESET"), _react.default.createElement(_DataGrid.default, {
|
|
97
|
+
return _react.default.createElement(_DataGrid.default, {
|
|
93
98
|
dark: true,
|
|
94
|
-
|
|
99
|
+
onRowClick: onRowClick,
|
|
100
|
+
onRowDoubleClick: onRowDoubleClick,
|
|
101
|
+
// allowChildRows
|
|
95
102
|
// onSelectionChange={onSelectionChange}
|
|
96
103
|
// selected={selected}
|
|
97
|
-
|
|
98
|
-
|
|
104
|
+
// contextMenuItems={contextMenuItems}
|
|
105
|
+
// customColumns={customColumns}
|
|
99
106
|
columns: columns,
|
|
100
|
-
|
|
107
|
+
// leftColumns={leftColumns}
|
|
101
108
|
gridOptions: {
|
|
102
|
-
defaultFilterValue: filterValue,
|
|
103
|
-
remoteFilter: false,
|
|
104
|
-
multiSelect: true,
|
|
105
|
-
pagination: 'local',
|
|
106
|
-
defaultLimit: 100,
|
|
107
|
-
limit: 100,
|
|
108
|
-
pageSizes: [100],
|
|
109
|
-
rowIndexColumn: true,
|
|
110
|
-
checkboxColumn: true
|
|
109
|
+
// defaultFilterValue: filterValue,
|
|
110
|
+
// remoteFilter: false,
|
|
111
|
+
// multiSelect: true,
|
|
112
|
+
// pagination: 'local',
|
|
113
|
+
// defaultLimit: 100,
|
|
114
|
+
// limit: 100,
|
|
115
|
+
// pageSizes: [100],
|
|
116
|
+
// rowIndexColumn: true,
|
|
117
|
+
// checkboxColumn: true,
|
|
111
118
|
},
|
|
112
119
|
dataSource: dataSource
|
|
113
|
-
})
|
|
120
|
+
});
|
|
114
121
|
}
|
|
115
122
|
var _default = ExampleGrid;
|
|
116
123
|
exports.default = _default;
|
package/dist/src/index.js
CHANGED
|
@@ -19,6 +19,6 @@ Object.keys(_DataGrid).forEach(function (key) {
|
|
|
19
19
|
});
|
|
20
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
21
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
-
var _default = _DataGrid.default; //const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
23
|
-
//root.render(<ExampleGrid />);
|
|
22
|
+
var _default = _DataGrid.default; // const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
23
|
+
// root.render(<ExampleGrid />);
|
|
24
24
|
exports.default = _default;
|
|
@@ -120,8 +120,42 @@ function DataGrid(props) {
|
|
|
120
120
|
} = props;
|
|
121
121
|
/* -------------------------------------------------------------------------- */
|
|
122
122
|
const gridRef = _react.default.useRef(null);
|
|
123
|
+
const click_data = _react.default.useRef(null);
|
|
123
124
|
const [menuAnchorEl, set_menuAnchorEl] = _react.default.useState(null);
|
|
124
125
|
const [menuRow, set_menuRow] = _react.default.useState(null);
|
|
126
|
+
_react.default.useEffect(() => {
|
|
127
|
+
click_data.current = {};
|
|
128
|
+
}, [dataSource]);
|
|
129
|
+
/* --------------------------------- events --------------------------------- */
|
|
130
|
+
const onRowContextMenu = (0, _react.useCallback)((rowProps, event) => {
|
|
131
|
+
if (_helpers.func_selection.has_selection()) return;
|
|
132
|
+
update_menuAnchorEl(_helpers.func_selection.getVirtualElement(event.clientX, event.clientY));
|
|
133
|
+
update_menuRow(rowProps.data);
|
|
134
|
+
event.preventDefault();
|
|
135
|
+
}, []);
|
|
136
|
+
const onRowClick = _react.default.useCallback((rowProps, event) => {
|
|
137
|
+
const nowDate = Date.now();
|
|
138
|
+
const lastclick = click_data.current[get_row_id(rowProps)];
|
|
139
|
+
if (lastclick) {
|
|
140
|
+
const diffTime = Math.abs(nowDate - lastclick);
|
|
141
|
+
if (diffTime < 400) {
|
|
142
|
+
props.onRowDoubleClick && props.onRowDoubleClick(rowProps.rowIndex, rowProps.data);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
click_data.current[get_row_id(rowProps)] = nowDate;
|
|
146
|
+
props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
147
|
+
}, []);
|
|
148
|
+
/* ------------------------------- ContextMenu ------------------------------ */
|
|
149
|
+
const update_menuAnchorEl = _react.default.useCallback(el => {
|
|
150
|
+
if (!el) {
|
|
151
|
+
set_menuAnchorEl(el);
|
|
152
|
+
} else if (menuAnchorEl) set_menuAnchorEl(null);
|
|
153
|
+
}, []);
|
|
154
|
+
const update_menuRow = _react.default.useCallback(r => {
|
|
155
|
+
if (!r) {
|
|
156
|
+
set_menuRow(r);
|
|
157
|
+
} else if (menuRow) set_menuRow(null);
|
|
158
|
+
}, []);
|
|
125
159
|
/* -------------------------------------------------------------------------- */
|
|
126
160
|
/* Create the grid */
|
|
127
161
|
/* -------------------------------------------------------------------------- */
|
|
@@ -130,7 +164,6 @@ function DataGrid(props) {
|
|
|
130
164
|
const licenseKey = props.licenseKey || get_default_key();
|
|
131
165
|
const events = {
|
|
132
166
|
onRowClick: onRowClick,
|
|
133
|
-
onRowDoubleClick: onRowDoubleClick,
|
|
134
167
|
onSkipChange: props.onSkipChange,
|
|
135
168
|
onLimitChange: props.onLimitChange,
|
|
136
169
|
onRowContextMenu: onRowContextMenu
|
|
@@ -154,7 +187,7 @@ function DataGrid(props) {
|
|
|
154
187
|
...props.gridOptions,
|
|
155
188
|
...forcedOptions
|
|
156
189
|
};
|
|
157
|
-
}, [props.gridOptions, base_gridOptions]);
|
|
190
|
+
}, [props.gridOptions, base_gridOptions, forcedOptions]);
|
|
158
191
|
const dynamic_gridOptions = _react.default.useMemo(() => {
|
|
159
192
|
const res = {};
|
|
160
193
|
dynamic_option_names.map(r => {
|
|
@@ -162,31 +195,6 @@ function DataGrid(props) {
|
|
|
162
195
|
});
|
|
163
196
|
return res;
|
|
164
197
|
}, dynamic_option_names.map(r => props[r]));
|
|
165
|
-
/* --------------------------------- events --------------------------------- */
|
|
166
|
-
const onRowContextMenu = (0, _react.useCallback)((rowProps, event) => {
|
|
167
|
-
if (_helpers.func_selection.has_selection()) return;
|
|
168
|
-
update_menuAnchorEl(_helpers.func_selection.getVirtualElement(event.clientX, event.clientY));
|
|
169
|
-
update_menuRow(rowProps.data);
|
|
170
|
-
event.preventDefault();
|
|
171
|
-
}, []);
|
|
172
|
-
const onRowClick = (0, _react.useCallback)((rowProps, event) => {
|
|
173
|
-
props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
174
|
-
}, []);
|
|
175
|
-
const onRowDoubleClick = _react.default.useCallback((event, rowProps) => {
|
|
176
|
-
props.onRowDoubleClick && props.onRowDoubleClick(rowProps.rowIndex, rowProps.data);
|
|
177
|
-
}, []);
|
|
178
|
-
/* ------------------------------- ContextMenu ------------------------------ */
|
|
179
|
-
const update_menuAnchorEl = _react.default.useCallback(el => {
|
|
180
|
-
if (!el) {
|
|
181
|
-
set_menuAnchorEl(el);
|
|
182
|
-
} else if (menuAnchorEl) set_menuAnchorEl(null);
|
|
183
|
-
}, []);
|
|
184
|
-
const update_menuRow = _react.default.useCallback(r => {
|
|
185
|
-
if (!r) {
|
|
186
|
-
set_menuRow(r);
|
|
187
|
-
} else if (menuRow) set_menuRow(null);
|
|
188
|
-
}, []);
|
|
189
|
-
/* -------------------------------------------------------------------------- */
|
|
190
198
|
// const { width, height, ref: resize_ref } = useResizeDetector();
|
|
191
199
|
return _react.default.createElement("div", {
|
|
192
200
|
className: (0, _clsx.default)(props.className, 'azgrid-nooverflow', 'azgrid-filler')
|
|
@@ -205,6 +213,9 @@ function DataGrid(props) {
|
|
|
205
213
|
}));
|
|
206
214
|
}
|
|
207
215
|
/* -------------------------------------------------------------------------- */
|
|
216
|
+
/* -------------------------------------------------------------------------- */
|
|
217
|
+
/* -------------------------------------------------------------------------- */
|
|
218
|
+
/* -------------------------------------------------------------------------- */
|
|
208
219
|
/**
|
|
209
220
|
* Gets name of a column from its column object
|
|
210
221
|
* @param obj
|
|
@@ -216,6 +227,17 @@ function get_col_name(obj) {
|
|
|
216
227
|
if (typeof obj != 'object') return 'default';
|
|
217
228
|
return obj.name || obj.field || obj.key || obj.columnName || 'default';
|
|
218
229
|
}
|
|
230
|
+
/**
|
|
231
|
+
* Gets name of a column from its column object
|
|
232
|
+
* @param obj
|
|
233
|
+
* @returns
|
|
234
|
+
*/
|
|
235
|
+
function get_row_id(obj) {
|
|
236
|
+
if (!obj) return 'default';
|
|
237
|
+
if (typeof obj == 'string') return obj;
|
|
238
|
+
if (typeof obj != 'object') return 'default';
|
|
239
|
+
return obj.__table_id || obj.id || 'default';
|
|
240
|
+
}
|
|
219
241
|
/**
|
|
220
242
|
* Gets default activation key for grid plugin
|
|
221
243
|
* @returns
|
package/package.json
CHANGED
package/src/example.tsx
CHANGED
|
@@ -35,24 +35,24 @@ function getData() {
|
|
|
35
35
|
const fd: any[] = [];
|
|
36
36
|
for (let index = 0; index < 200; index++) {
|
|
37
37
|
fd.push({ __table_id: String(index), name: 'user-' + index, age: 20 });
|
|
38
|
-
if (index % 5 == 0) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
38
|
+
//if (index % 5 == 0) {
|
|
39
|
+
// const sub_selfid = 's' + index;
|
|
40
|
+
// fd.push({
|
|
41
|
+
// __table_id: sub_selfid,
|
|
42
|
+
// __parent__table_id: String(index),
|
|
43
|
+
// name: 'sub-' + index,
|
|
44
|
+
// age: 20,
|
|
45
|
+
// });
|
|
46
|
+
// if (index % 2 == 0) {
|
|
47
|
+
// const sub2_selfid = 'ss' + index;
|
|
48
|
+
// fd.push({
|
|
49
|
+
// __table_id: sub2_selfid,
|
|
50
|
+
// __parent__table_id: sub_selfid,
|
|
51
|
+
// name: 'sub2-' + index,
|
|
52
|
+
// age: 20,
|
|
53
|
+
// });
|
|
54
|
+
// }
|
|
55
|
+
//}
|
|
56
56
|
}
|
|
57
57
|
return fd;
|
|
58
58
|
}
|
|
@@ -73,37 +73,45 @@ export function ExampleGrid() {
|
|
|
73
73
|
[ds_reset]
|
|
74
74
|
);
|
|
75
75
|
|
|
76
|
+
const onRowDoubleClick = React.useCallback((index: number, rowdata: any) => {
|
|
77
|
+
console.log(rowdata?.data || rowdata);
|
|
78
|
+
}, []);
|
|
79
|
+
const onRowClick = React.useCallback((index: number, rowdata: any) => {
|
|
80
|
+
//console.log(rowdata?.data || rowdata);
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
76
83
|
function rst_ds() {
|
|
77
84
|
//console.log('rst_ds');
|
|
78
85
|
set_ds_reset((s) => s + 1);
|
|
79
86
|
}
|
|
80
87
|
|
|
81
88
|
return (
|
|
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
|
-
|
|
89
|
+
<AzGrid
|
|
90
|
+
dark
|
|
91
|
+
onRowClick={onRowClick}
|
|
92
|
+
onRowDoubleClick={onRowDoubleClick}
|
|
93
|
+
// allowChildRows
|
|
94
|
+
// onSelectionChange={onSelectionChange}
|
|
95
|
+
// selected={selected}
|
|
96
|
+
// contextMenuItems={contextMenuItems}
|
|
97
|
+
// customColumns={customColumns}
|
|
98
|
+
columns={columns}
|
|
99
|
+
// leftColumns={leftColumns}
|
|
100
|
+
gridOptions={
|
|
101
|
+
{
|
|
102
|
+
// defaultFilterValue: filterValue,
|
|
103
|
+
// remoteFilter: false,
|
|
104
|
+
// multiSelect: true,
|
|
105
|
+
// pagination: 'local',
|
|
106
|
+
// defaultLimit: 100,
|
|
107
|
+
// limit: 100,
|
|
108
|
+
// pageSizes: [100],
|
|
109
|
+
// rowIndexColumn: true,
|
|
110
|
+
// checkboxColumn: true,
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
dataSource={dataSource}
|
|
114
|
+
/>
|
|
107
115
|
);
|
|
108
116
|
}
|
|
109
117
|
export default ExampleGrid;
|
package/src/index.tsx
CHANGED
|
@@ -7,5 +7,5 @@ import React from 'react';
|
|
|
7
7
|
import ReactDOM from 'react-dom/client';
|
|
8
8
|
export default AzGrid;
|
|
9
9
|
|
|
10
|
-
//const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
11
|
-
//root.render(<ExampleGrid />);
|
|
10
|
+
// const root = ReactDOM.createRoot(document.getElementById('testroot') as HTMLElement);
|
|
11
|
+
// root.render(<ExampleGrid />);
|
package/src/views/DataGrid.tsx
CHANGED
|
@@ -220,10 +220,49 @@ function DataGrid(props: DataGridProps) {
|
|
|
220
220
|
|
|
221
221
|
/* -------------------------------------------------------------------------- */
|
|
222
222
|
const gridRef = React.useRef<any>(null);
|
|
223
|
+
const click_data = React.useRef<any>(null);
|
|
223
224
|
|
|
224
225
|
const [menuAnchorEl, set_menuAnchorEl] = React.useState<any>(null);
|
|
225
226
|
const [menuRow, set_menuRow] = React.useState<any>(null);
|
|
226
227
|
|
|
228
|
+
React.useEffect(() => {
|
|
229
|
+
click_data.current = {};
|
|
230
|
+
}, [dataSource]);
|
|
231
|
+
/* --------------------------------- events --------------------------------- */
|
|
232
|
+
|
|
233
|
+
const onRowContextMenu = useCallback((rowProps, event) => {
|
|
234
|
+
if (func_selection.has_selection()) return;
|
|
235
|
+
update_menuAnchorEl(func_selection.getVirtualElement(event.clientX, event.clientY));
|
|
236
|
+
update_menuRow(rowProps.data);
|
|
237
|
+
event.preventDefault();
|
|
238
|
+
}, []);
|
|
239
|
+
const onRowClick = React.useCallback((rowProps, event) => {
|
|
240
|
+
const nowDate = Date.now();
|
|
241
|
+
const lastclick: number = click_data.current[get_row_id(rowProps)];
|
|
242
|
+
if (lastclick) {
|
|
243
|
+
const diffTime = Math.abs(nowDate - lastclick);
|
|
244
|
+
if (diffTime < 400) {
|
|
245
|
+
props.onRowDoubleClick &&
|
|
246
|
+
props.onRowDoubleClick(rowProps.rowIndex, rowProps.data);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
click_data.current[get_row_id(rowProps)] = nowDate;
|
|
251
|
+
props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
252
|
+
}, []);
|
|
253
|
+
|
|
254
|
+
/* ------------------------------- ContextMenu ------------------------------ */
|
|
255
|
+
const update_menuAnchorEl = React.useCallback((el) => {
|
|
256
|
+
if (!el) {
|
|
257
|
+
set_menuAnchorEl(el);
|
|
258
|
+
} else if (menuAnchorEl) set_menuAnchorEl(null);
|
|
259
|
+
}, []);
|
|
260
|
+
const update_menuRow = React.useCallback((r) => {
|
|
261
|
+
if (!r) {
|
|
262
|
+
set_menuRow(r);
|
|
263
|
+
} else if (menuRow) set_menuRow(null);
|
|
264
|
+
}, []);
|
|
265
|
+
|
|
227
266
|
/* -------------------------------------------------------------------------- */
|
|
228
267
|
/* Create the grid */
|
|
229
268
|
/* -------------------------------------------------------------------------- */
|
|
@@ -233,7 +272,6 @@ function DataGrid(props: DataGridProps) {
|
|
|
233
272
|
const licenseKey = props.licenseKey || get_default_key();
|
|
234
273
|
const events: GridOptions = {
|
|
235
274
|
onRowClick: onRowClick,
|
|
236
|
-
onRowDoubleClick: onRowDoubleClick,
|
|
237
275
|
onSkipChange: props.onSkipChange,
|
|
238
276
|
onLimitChange: props.onLimitChange,
|
|
239
277
|
onRowContextMenu: onRowContextMenu,
|
|
@@ -250,7 +288,7 @@ function DataGrid(props: DataGridProps) {
|
|
|
250
288
|
|
|
251
289
|
const static_gridOptions = React.useMemo<GridOptions>(() => {
|
|
252
290
|
return { ...base_gridOptions, ...props.gridOptions, ...forcedOptions };
|
|
253
|
-
}, [props.gridOptions, base_gridOptions]);
|
|
291
|
+
}, [props.gridOptions, base_gridOptions, forcedOptions]);
|
|
254
292
|
|
|
255
293
|
const dynamic_gridOptions = React.useMemo<GridOptions>(
|
|
256
294
|
() => {
|
|
@@ -263,34 +301,6 @@ function DataGrid(props: DataGridProps) {
|
|
|
263
301
|
dynamic_option_names.map((r) => props[r])
|
|
264
302
|
);
|
|
265
303
|
|
|
266
|
-
/* --------------------------------- events --------------------------------- */
|
|
267
|
-
|
|
268
|
-
const onRowContextMenu = useCallback((rowProps, event) => {
|
|
269
|
-
if (func_selection.has_selection()) return;
|
|
270
|
-
update_menuAnchorEl(func_selection.getVirtualElement(event.clientX, event.clientY));
|
|
271
|
-
update_menuRow(rowProps.data);
|
|
272
|
-
event.preventDefault();
|
|
273
|
-
}, []);
|
|
274
|
-
const onRowClick = useCallback((rowProps, event) => {
|
|
275
|
-
props.onRowClick && props.onRowClick(rowProps.rowIndex, rowProps.data);
|
|
276
|
-
}, []);
|
|
277
|
-
const onRowDoubleClick = React.useCallback((event, rowProps) => {
|
|
278
|
-
props.onRowDoubleClick && props.onRowDoubleClick(rowProps.rowIndex, rowProps.data);
|
|
279
|
-
}, []);
|
|
280
|
-
|
|
281
|
-
/* ------------------------------- ContextMenu ------------------------------ */
|
|
282
|
-
const update_menuAnchorEl = React.useCallback((el) => {
|
|
283
|
-
if (!el) {
|
|
284
|
-
set_menuAnchorEl(el);
|
|
285
|
-
} else if (menuAnchorEl) set_menuAnchorEl(null);
|
|
286
|
-
}, []);
|
|
287
|
-
const update_menuRow = React.useCallback((r) => {
|
|
288
|
-
if (!r) {
|
|
289
|
-
set_menuRow(r);
|
|
290
|
-
} else if (menuRow) set_menuRow(null);
|
|
291
|
-
}, []);
|
|
292
|
-
|
|
293
|
-
/* -------------------------------------------------------------------------- */
|
|
294
304
|
// const { width, height, ref: resize_ref } = useResizeDetector();
|
|
295
305
|
|
|
296
306
|
return (
|
|
@@ -313,6 +323,9 @@ function DataGrid(props: DataGridProps) {
|
|
|
313
323
|
);
|
|
314
324
|
}
|
|
315
325
|
|
|
326
|
+
/* -------------------------------------------------------------------------- */
|
|
327
|
+
/* -------------------------------------------------------------------------- */
|
|
328
|
+
/* -------------------------------------------------------------------------- */
|
|
316
329
|
/* -------------------------------------------------------------------------- */
|
|
317
330
|
|
|
318
331
|
/**
|
|
@@ -326,6 +339,17 @@ function get_col_name(obj: any): string {
|
|
|
326
339
|
if (typeof obj != 'object') return 'default';
|
|
327
340
|
return obj.name || obj.field || obj.key || obj.columnName || 'default';
|
|
328
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Gets name of a column from its column object
|
|
344
|
+
* @param obj
|
|
345
|
+
* @returns
|
|
346
|
+
*/
|
|
347
|
+
function get_row_id(obj: any): any {
|
|
348
|
+
if (!obj) return 'default';
|
|
349
|
+
if (typeof obj == 'string') return obj;
|
|
350
|
+
if (typeof obj != 'object') return 'default';
|
|
351
|
+
return obj.__table_id || obj.id || 'default';
|
|
352
|
+
}
|
|
329
353
|
|
|
330
354
|
/**
|
|
331
355
|
* Gets default activation key for grid plugin
|