@azrico/reactgrid 1.2.49 → 1.2.50

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.2.50](https://github.com/Azrideus/azrico-reactgrid/compare/v1.2.10...v1.2.50) (2023-07-09)
6
+
7
+
8
+ ### Features
9
+
10
+ * editable can be a function ([6ea857e](https://github.com/Azrideus/azrico-reactgrid/commit/6ea857e4f403d2a334dc5e74065f6b8033277ca4))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * DataGridDelayedSizeWrapper actual delayed ([2ddfd2f](https://github.com/Azrideus/azrico-reactgrid/commit/2ddfd2fb58c90bd906e1330f22f0ef7468d34afb))
16
+ * onCellSelectionChange ([95c8f54](https://github.com/Azrideus/azrico-reactgrid/commit/95c8f540e94dde0c7e245fb29fb6afc7172957ec))
17
+ * styling ([9018f75](https://github.com/Azrideus/azrico-reactgrid/commit/9018f7593e253720f751f52855a2d956dfc578ed))
18
+
5
19
  ### [1.2.49](https://github.com/Azrideus/azrico-reactgrid/compare/v1.2.10...v1.2.49) (2023-07-09)
6
20
 
7
21
 
@@ -40,7 +40,6 @@ const columns = [{
40
40
  defaultFlex: 1
41
41
  }];
42
42
  const editableColumns = ['job', 'age'];
43
- const contextMenuItems = ['test'];
44
43
  function getData(delta, max = 200) {
45
44
  const fd = [];
46
45
  console.log('Delta:', delta);
@@ -75,22 +74,29 @@ function ExampleGrid() {
75
74
  const [ds_reset, set_ds_reset] = _react.default.useState(0);
76
75
  const [delta, set_delta] = _react.default.useState({});
77
76
  const [delayed_reload, set_delayed_reload] = _react.default.useState(false);
78
- const dataSource = _react.default.useCallback(async dt => {
79
- //console.log('Start loading');
80
- return await new Promise(resolve => {
81
- setTimeout(() => {
82
- resolve(getData(delta));
83
- }, 1000);
84
- });
85
- }, [ds_reset, delta]);
86
- const details_dataSource = _react.default.useCallback(async dt => {
87
- //console.log('Start loading');
88
- return await new Promise(resolve => {
89
- setTimeout(() => {
90
- resolve(getData(delta, 5));
91
- }, 1000);
92
- });
93
- }, [ds_reset, delta]);
77
+ const dataSource = _react.default.useMemo(() => getData(delta), []);
78
+ // const dataSource = React.useCallback(
79
+ // async (dt) => {
80
+ // //console.log('Start loading');
81
+ // return await new Promise((resolve) => {
82
+ // setTimeout(() => {
83
+ // resolve(getData(delta));
84
+ // }, 1000);
85
+ // });
86
+ // },
87
+ // [ds_reset, delta]
88
+ // );
89
+ // const details_dataSource = React.useCallback(
90
+ // async (dt) => {
91
+ // //console.log('Start loading');
92
+ // return await new Promise((resolve) => {
93
+ // setTimeout(() => {
94
+ // resolve(getData(delta, 5));
95
+ // }, 1000);
96
+ // });
97
+ // },
98
+ // [ds_reset, delta]
99
+ // );
94
100
  function onEditComplete(params) {
95
101
  const {
96
102
  value,
@@ -126,10 +132,17 @@ function ExampleGrid() {
126
132
  render: r => r.value + '^'
127
133
  }];
128
134
  }, [delayed_reload]);
135
+ const contextMenuItems = _react.default.useCallback(product => {
136
+ return [{
137
+ type: 'text',
138
+ content: product.name
139
+ }];
140
+ }, []);
129
141
  return _react.default.createElement(_DataGrid.default, {
130
142
  dark: true,
131
143
  delayedSize: true,
132
- details_dataSource: details_dataSource,
144
+ // details_dataSource={details_dataSource}
145
+ dataSource: dataSource,
133
146
  details_columns: columns,
134
147
  onRowClick: onRowClick,
135
148
  onRowDoubleClick: onRowDoubleClick,
@@ -153,8 +166,7 @@ function ExampleGrid() {
153
166
  // pageSizes: [100],
154
167
  // rowIndexColumn: true,
155
168
  // checkboxColumn: true,
156
- },
157
- dataSource: dataSource
169
+ }
158
170
  });
159
171
  }
160
172
  var _default = ExampleGrid;
@@ -37,3 +37,10 @@ export declare function set_row_id(obj: any, val: undefined | string): any;
37
37
  */
38
38
  export declare function get_default_key(): string;
39
39
  export declare function validateCache(current: any, old: any, looseCheck?: boolean): boolean;
40
+ /**
41
+ * find the real index of the given row data
42
+ * sometimes when we scroll the rowData prop becomes invalid
43
+ * but we can manually find the correct data by reading the id from clicked item's Html props
44
+ * @param view
45
+ */
46
+ export declare function find_realData(alldata: any[], view: any, def?: undefined): any;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ApplyColumnData = ApplyColumnData;
7
7
  exports.ApplyDataSource = ApplyDataSource;
8
+ exports.find_realData = find_realData;
8
9
  exports.get_col_header = get_col_header;
9
10
  exports.get_col_name = get_col_name;
10
11
  exports.get_default_key = get_default_key;
@@ -260,9 +261,8 @@ function get_col_header(obj) {
260
261
  * @returns
261
262
  */
262
263
  function get_row_id(obj) {
263
- if (!obj) return undefined;
264
- if (typeof obj == 'string') return obj;
265
- if (typeof obj != 'object') return undefined;
264
+ if (typeof obj === 'string') return obj;
265
+ if (typeof obj !== 'object' || !obj) return undefined;
266
266
  return obj.__table_id || obj.id || undefined;
267
267
  }
268
268
  function set_row_id(obj, val) {
@@ -283,4 +283,32 @@ function validateCache(current, old, looseCheck = false) {
283
283
  if (looseCheck) return true;
284
284
  if (current.ds != old.ds) return false;
285
285
  return true;
286
+ }
287
+ /**
288
+ * find the real index of the given row data
289
+ * @param view
290
+ */
291
+ function find_realIndex(view) {
292
+ let current_parent = view;
293
+ for (let index = 0; index < 3; index++) {
294
+ var _current_parent;
295
+ current_parent = current_parent.parentElement;
296
+ const dataId = (_current_parent = current_parent) === null || _current_parent === void 0 ? void 0 : _current_parent.getAttribute('data-row-id');
297
+ if (dataId) return dataId;
298
+ }
299
+ return -1;
300
+ }
301
+ /**
302
+ * find the real index of the given row data
303
+ * sometimes when we scroll the rowData prop becomes invalid
304
+ * but we can manually find the correct data by reading the id from clicked item's Html props
305
+ * @param view
306
+ */
307
+ function find_realData(alldata, view, def = undefined) {
308
+ if (!Array.isArray(alldata)) return def;
309
+ const rid = find_realIndex(view);
310
+ console.log('rid:', rid);
311
+ if (rid === -1) return def;
312
+ // console.log('dataSource', alldata);
313
+ return alldata.find(s => get_row_id(s) === rid);
286
314
  }
@@ -12,12 +12,14 @@ require("../themes/base_styles.css");
12
12
  require("../themes/grid.css");
13
13
  var _func_grid = require("../func/func_grid");
14
14
  var _controls = require("@azrico/controls");
15
- var _react = _interopRequireDefault(require("react"));
15
+ var _react = _interopRequireWildcard(require("react"));
16
16
  var _func_child = require("../func/func_child");
17
17
  var _reactdatagridEnterprise = _interopRequireDefault(require("@inovua/reactdatagrid-enterprise"));
18
18
  var _clsx = _interopRequireDefault(require("clsx"));
19
19
  var _reactUseSize = require("react-use-size");
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ 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); }
22
+ 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; }
21
23
  /* -------------------------------------------------------------------------- */
22
24
  const defaultOptions = {
23
25
  //filterTypes: defaultfilterTypes,
@@ -50,6 +52,7 @@ function AzGrid(props) {
50
52
  /* -------------------------------------------------------------------------- */
51
53
  const cached_data = _react.default.useRef();
52
54
  const last_cache_info = _react.default.useRef();
55
+ const rawDataSource = props.dataSource;
53
56
  const dataSource = _react.default.useCallback(async dt => {
54
57
  return await (0, _func_grid.ApplyDataSource)(props.dataSource, {
55
58
  skip: dt.skip,
@@ -102,6 +105,7 @@ function AzGrid(props) {
102
105
  dynamic_gridOptions: dynamic_gridOptions,
103
106
  columns: cached_columns,
104
107
  dataSource: dataSource,
108
+ rawDataSource: rawDataSource,
105
109
  highlightedRow: props.highlightedRow
106
110
  });
107
111
  }
@@ -136,11 +140,12 @@ function DataGridEventsWrapper(props) {
136
140
  /* ------------------------------- ContextMenu ------------------------------ */
137
141
  const onRowContextMenu = _react.default.useCallback((rowProps, event) => {
138
142
  if (!rowProps || !rowProps.data || _func_child.func_selection.has_selection()) return;
143
+ const realRow = (0, _func_grid.find_realData)(props.rawDataSource, event.target, rowProps.data);
139
144
  const anEl = _func_child.func_selection.getVirtualElement(event.clientX, event.clientY);
140
- update_menuRow(rowProps.data, anEl);
145
+ update_menuRow(realRow, anEl);
141
146
  }, []);
142
147
  const update_menuRow = _react.default.useCallback((r = null, el = null) => {
143
- console.log('Set menuRow:', r);
148
+ // console.log('Set menuRow:', r);
144
149
  set_menuRow(r || null);
145
150
  set_menuAnchorEl(el || null);
146
151
  }, []);
@@ -152,8 +157,6 @@ function DataGridEventsWrapper(props) {
152
157
  menuProps.onDismiss();
153
158
  update_menuRow();
154
159
  }
155
- console.log('rowProps.data:', rowProps.data);
156
- console.log('menuRow:', menuRow);
157
160
  return _react.default.createElement(_controls.ContextMenu, {
158
161
  menuAnchorEl: menuAnchorEl,
159
162
  menuRow: menuRow,
@@ -161,6 +164,12 @@ function DataGridEventsWrapper(props) {
161
164
  menu_items: props.contextMenuItems
162
165
  });
163
166
  }, [props.contextMenuItems, menuAnchorEl, menuRow, update_menuRow]);
167
+ /* -------------------------------------------------------------------------- */
168
+ const onRenderRow = (0, _react.useCallback)(rowProps => {
169
+ // save the original handlers to be called later
170
+ rowProps['data-row-id'] = (0, _func_grid.get_row_id)(rowProps.data);
171
+ }, []);
172
+ /* -------------------------------------------------------------------------- */
164
173
  /**
165
174
  * Merge click events into grid options
166
175
  */
@@ -172,12 +181,16 @@ function DataGridEventsWrapper(props) {
172
181
  const contextmenuProps = {
173
182
  renderRowContextMenu: renderRowContextMenu
174
183
  };
184
+ const renderProps = {
185
+ onRenderRow: onRenderRow
186
+ };
175
187
  return {
176
188
  ...props.static_gridOptions,
177
189
  ...events,
178
- ...contextmenuProps
190
+ ...contextmenuProps,
191
+ ...renderProps
179
192
  };
180
- }, [props.static_gridOptions, onRowClick, onRowContextMenu, renderRowContextMenu]);
193
+ }, [props.static_gridOptions, renderRowContextMenu]);
181
194
  /* -------------------------------------------------------------------------- */
182
195
  return props.details_dataSource ? _react.default.createElement(DataGridDetailsWrapper, {
183
196
  ...props,
@@ -193,7 +206,7 @@ function DataGridDetailsWrapper(props) {
193
206
  }, [props.details_columns]);
194
207
  const cached_data = _react.default.useRef();
195
208
  const last_cache_info = _react.default.useRef();
196
- const dataSource = _react.default.useCallback(async dt => {
209
+ const details_dataSource = _react.default.useCallback(async dt => {
197
210
  const res = await (0, _func_grid.ApplyDataSource)(props.details_dataSource, {
198
211
  skip: dt.skip,
199
212
  limit: dt.limit,
@@ -201,13 +214,13 @@ function DataGridDetailsWrapper(props) {
201
214
  last_cache_info: last_cache_info
202
215
  });
203
216
  return res;
204
- }, [props.dataSource]);
217
+ }, [props.details_dataSource]);
205
218
  const renderDetailsGrid = ({
206
219
  data
207
220
  }) => {
208
221
  return _react.default.createElement(_reactdatagridEnterprise.default, {
209
222
  defaultFilterValue: props.details_filter,
210
- dataSource: dataSource,
223
+ dataSource: details_dataSource,
211
224
  columns: cached_details_columns
212
225
  });
213
226
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/reactgrid",
3
- "version": "1.2.49",
3
+ "version": "1.2.50",
4
4
  "main": "dist/index.js",
5
5
  "description": "React Datagrid",
6
6
  "author": "Azrideus <MehrdadTavangar@gmail.com>",
@@ -33,7 +33,7 @@
33
33
  "@azrico/object": "^1.4.35",
34
34
  "@emotion/react": "^11.9.3",
35
35
  "@emotion/styled": "^11.9.3",
36
- "@inovua/reactdatagrid-enterprise": "^5.8.5",
36
+ "@inovua/reactdatagrid-enterprise": "^5.9.5",
37
37
  "clsx": "^1.2.1",
38
38
  "react": "^18.2.0",
39
39
  "react-use-size": "^3.0.1"
@@ -43,7 +43,7 @@
43
43
  "@azrico/object": ">=1.4.12",
44
44
  "@emotion/react": ">=11.9.3",
45
45
  "@emotion/styled": ">=11.9.3",
46
- "@inovua/reactdatagrid-enterprise": ">=5.8.5",
46
+ "@inovua/reactdatagrid-enterprise": ">=5.9.5",
47
47
  "clsx": ">=1.2.1",
48
48
  "react": ">=18.2.0",
49
49
  "react-use-size": ">=3.0.1"
package/src/example.tsx CHANGED
@@ -27,7 +27,6 @@ const columns = [
27
27
  ];
28
28
 
29
29
  const editableColumns = ['job', 'age'];
30
- const contextMenuItems = ['test'];
31
30
 
32
31
  function getData(delta: any, max = 200) {
33
32
  const fd: any[] = [];
@@ -67,28 +66,29 @@ export function ExampleGrid() {
67
66
  const [delta, set_delta] = React.useState({});
68
67
  const [delayed_reload, set_delayed_reload] = React.useState(false);
69
68
 
70
- const dataSource = React.useCallback(
71
- async (dt) => {
72
- //console.log('Start loading');
73
- return await new Promise((resolve) => {
74
- setTimeout(() => {
75
- resolve(getData(delta));
76
- }, 1000);
77
- });
78
- },
79
- [ds_reset, delta]
80
- );
81
- const details_dataSource = React.useCallback(
82
- async (dt) => {
83
- //console.log('Start loading');
84
- return await new Promise((resolve) => {
85
- setTimeout(() => {
86
- resolve(getData(delta, 5));
87
- }, 1000);
88
- });
89
- },
90
- [ds_reset, delta]
91
- );
69
+ const dataSource = React.useMemo(() => getData(delta), []);
70
+ // const dataSource = React.useCallback(
71
+ // async (dt) => {
72
+ // //console.log('Start loading');
73
+ // return await new Promise((resolve) => {
74
+ // setTimeout(() => {
75
+ // resolve(getData(delta));
76
+ // }, 1000);
77
+ // });
78
+ // },
79
+ // [ds_reset, delta]
80
+ // );
81
+ // const details_dataSource = React.useCallback(
82
+ // async (dt) => {
83
+ // //console.log('Start loading');
84
+ // return await new Promise((resolve) => {
85
+ // setTimeout(() => {
86
+ // resolve(getData(delta, 5));
87
+ // }, 1000);
88
+ // });
89
+ // },
90
+ // [ds_reset, delta]
91
+ // );
92
92
 
93
93
  function onEditComplete(params) {
94
94
  const { value, columnId, rowId, ...rest } = params;
@@ -117,18 +117,28 @@ export function ExampleGrid() {
117
117
  return [{ name: 'name', render: (r) => r.value + '^' }];
118
118
  }, [delayed_reload]);
119
119
 
120
+ const contextMenuItems = React.useCallback((product: any) => {
121
+ return [
122
+ {
123
+ type: 'text',
124
+ content: product.name,
125
+ },
126
+ ];
127
+ }, []);
128
+
120
129
  return (
121
130
  <AzGrid
122
131
  dark
123
132
  delayedSize
124
- details_dataSource={details_dataSource}
133
+ // details_dataSource={details_dataSource}
134
+ dataSource={dataSource}
125
135
  details_columns={columns}
126
136
  onRowClick={onRowClick}
127
137
  onRowDoubleClick={onRowDoubleClick}
128
138
  allowChildRows
129
139
  // onSelectionChange={onSelectionChange}
130
140
  // selected={selected}
131
- contextMenuItems={contextMenuItems}
141
+ contextMenuItems={contextMenuItems as any}
132
142
  customColumns={customColumns}
133
143
  columns={columns}
134
144
  editableColumns={editableColumns}
@@ -148,7 +158,6 @@ export function ExampleGrid() {
148
158
  // checkboxColumn: true,
149
159
  }
150
160
  }
151
- dataSource={dataSource}
152
161
  />
153
162
  );
154
163
  }
@@ -264,9 +264,8 @@ export function get_col_header(obj: any): string {
264
264
  * @returns
265
265
  */
266
266
  export function get_row_id(obj: any): any {
267
- if (!obj) return undefined;
268
- if (typeof obj == 'string') return obj;
269
- if (typeof obj != 'object') return undefined;
267
+ if (typeof obj === 'string') return obj;
268
+ if (typeof obj !== 'object' || !obj) return undefined;
270
269
  return obj.__table_id || obj.id || undefined;
271
270
  }
272
271
  export function set_row_id(obj: any, val: undefined | string): any {
@@ -293,3 +292,33 @@ export function validateCache(current: any, old: any, looseCheck = false) {
293
292
  if (current.ds != old.ds) return false;
294
293
  return true;
295
294
  }
295
+
296
+ /**
297
+ * find the real index of the given row data
298
+ * @param view
299
+ */
300
+ function find_realIndex(view) {
301
+ let current_parent = view;
302
+
303
+ for (let index = 0; index < 3; index++) {
304
+ current_parent = current_parent.parentElement;
305
+ const dataId = current_parent?.getAttribute('data-row-id');
306
+ if (dataId) return dataId;
307
+ }
308
+ return -1;
309
+ }
310
+
311
+ /**
312
+ * find the real index of the given row data
313
+ * sometimes when we scroll the rowData prop becomes invalid
314
+ * but we can manually find the correct data by reading the id from clicked item's Html props
315
+ * @param view
316
+ */
317
+ export function find_realData(alldata: any[], view, def = undefined) {
318
+ if (!Array.isArray(alldata)) return def;
319
+ const rid = find_realIndex(view);
320
+ console.log('rid:', rid);
321
+ if (rid === -1) return def;
322
+ // console.log('dataSource', alldata);
323
+ return alldata.find((s) => get_row_id(s) === rid);
324
+ }
@@ -8,6 +8,7 @@ import {
8
8
  ApplyColumnData,
9
9
  ApplyDataSource,
10
10
  ModifyFields,
11
+ find_realData,
11
12
  get_default_key,
12
13
  get_row_id,
13
14
  validateCache,
@@ -73,7 +74,7 @@ export type AzGridOptions = Partial<TypeDataGridProps>;
73
74
  /* -------------------------------------------------------------------------- */
74
75
  export type AzGridProps = {
75
76
  dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
76
- details_dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>);
77
+ details_dataSource?: any[] | ((args: any) => any[] | Promise<any[] | any>); //details is rendered under each row
77
78
  details_columns?: LooseColumnDefinition[];
78
79
  details_filter?: FilterValues;
79
80
 
@@ -180,6 +181,7 @@ export function AzGrid(props: AzGridProps) {
180
181
  const cached_data = React.useRef<any>();
181
182
  const last_cache_info = React.useRef<any>();
182
183
 
184
+ const rawDataSource = props.dataSource;
183
185
  const dataSource = React.useCallback(
184
186
  async (dt) => {
185
187
  return await ApplyDataSource(props.dataSource, {
@@ -242,6 +244,7 @@ export function AzGrid(props: AzGridProps) {
242
244
  dynamic_gridOptions={dynamic_gridOptions}
243
245
  columns={cached_columns}
244
246
  dataSource={dataSource}
247
+ rawDataSource={rawDataSource}
245
248
  highlightedRow={props.highlightedRow}
246
249
  />
247
250
  );
@@ -253,7 +256,7 @@ export function AzGrid(props: AzGridProps) {
253
256
  * @param props
254
257
  * @returns
255
258
  */
256
- function DataGridEventsWrapper(props: DataGridWrapperProps) {
259
+ function DataGridEventsWrapper(props: DataGridWrapperProps & { rawDataSource: any }) {
257
260
  /* -------------------------------------------------------------------------- */
258
261
 
259
262
  const click_data = React.useRef<any>(null);
@@ -291,12 +294,13 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
291
294
  /* ------------------------------- ContextMenu ------------------------------ */
292
295
  const onRowContextMenu = React.useCallback((rowProps, event) => {
293
296
  if (!rowProps || !rowProps.data || func_selection.has_selection()) return;
297
+ const realRow = find_realData(props.rawDataSource, event.target, rowProps.data);
294
298
  const anEl = func_selection.getVirtualElement(event.clientX, event.clientY);
295
- update_menuRow(rowProps.data, anEl);
299
+ update_menuRow(realRow, anEl);
296
300
  }, []);
297
301
 
298
302
  const update_menuRow = React.useCallback((r: any = null, el: any = null) => {
299
- console.log('Set menuRow:', r);
303
+ // console.log('Set menuRow:', r);
300
304
  set_menuRow(r || null);
301
305
  set_menuAnchorEl(el || null);
302
306
  }, []);
@@ -308,8 +312,6 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
308
312
  menuProps.onDismiss();
309
313
  update_menuRow();
310
314
  }
311
- console.log('rowProps.data:', rowProps.data);
312
- console.log('menuRow:', menuRow);
313
315
 
314
316
  return (
315
317
  <ContextMenu
@@ -322,6 +324,12 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
322
324
  },
323
325
  [props.contextMenuItems, menuAnchorEl, menuRow, update_menuRow]
324
326
  );
327
+ /* -------------------------------------------------------------------------- */
328
+ const onRenderRow = useCallback((rowProps) => {
329
+ // save the original handlers to be called later
330
+ rowProps['data-row-id'] = get_row_id(rowProps.data);
331
+ }, []);
332
+ /* -------------------------------------------------------------------------- */
325
333
  /**
326
334
  * Merge click events into grid options
327
335
  */
@@ -333,8 +341,16 @@ function DataGridEventsWrapper(props: DataGridWrapperProps) {
333
341
  const contextmenuProps: AzGridOptions = {
334
342
  renderRowContextMenu: renderRowContextMenu,
335
343
  };
336
- return { ...props.static_gridOptions, ...events, ...contextmenuProps };
337
- }, [props.static_gridOptions, onRowClick, onRowContextMenu, renderRowContextMenu]);
344
+ const renderProps: any = {
345
+ onRenderRow: onRenderRow,
346
+ };
347
+ return {
348
+ ...props.static_gridOptions,
349
+ ...events,
350
+ ...contextmenuProps,
351
+ ...renderProps,
352
+ };
353
+ }, [props.static_gridOptions, renderRowContextMenu]);
338
354
 
339
355
  /* -------------------------------------------------------------------------- */
340
356
 
@@ -353,7 +369,7 @@ function DataGridDetailsWrapper(props: DataGridWrapperProps) {
353
369
  const cached_data = React.useRef<any>();
354
370
  const last_cache_info = React.useRef<any>();
355
371
 
356
- const dataSource = React.useCallback(
372
+ const details_dataSource = React.useCallback(
357
373
  async (dt) => {
358
374
  const res = await ApplyDataSource(props.details_dataSource, {
359
375
  skip: dt.skip,
@@ -363,13 +379,13 @@ function DataGridDetailsWrapper(props: DataGridWrapperProps) {
363
379
  });
364
380
  return res;
365
381
  },
366
- [props.dataSource]
382
+ [props.details_dataSource]
367
383
  );
368
384
  const renderDetailsGrid = ({ data }) => {
369
385
  return (
370
386
  <ReactDataGrid
371
387
  defaultFilterValue={props.details_filter}
372
- dataSource={dataSource}
388
+ dataSource={details_dataSource}
373
389
  columns={cached_details_columns}
374
390
  ></ReactDataGrid>
375
391
  );