@azrico/reactgrid 1.0.22 → 1.0.23
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/views/DataGrid.js +8 -15
- package/package.json +1 -1
- package/src/views/DataGrid.tsx +10 -12
|
@@ -43,25 +43,18 @@ function AzGrid(props) {
|
|
|
43
43
|
/* Row changes */
|
|
44
44
|
/* -------------------------------------------------------------------------- */
|
|
45
45
|
const dataSource = _react.default.useCallback(async dt => {
|
|
46
|
-
let result_rows = [];
|
|
47
46
|
let result_data = undefined;
|
|
48
47
|
if (typeof props.dataSource === 'function') {
|
|
49
48
|
result_data = await props.dataSource(dt);
|
|
50
|
-
if (typeof result_data === 'object') {
|
|
51
|
-
result_rows = result_data.data;
|
|
52
|
-
} else result_rows = result_data;
|
|
53
|
-
} else {
|
|
54
|
-
result_rows = props.dataSource || [];
|
|
55
49
|
}
|
|
56
|
-
if (!
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return result_rows;
|
|
50
|
+
if (!result_data) result_data = [];
|
|
51
|
+
if (Array.isArray(result_data) || typeof result_data !== 'object') result_data = {
|
|
52
|
+
data: result_data
|
|
53
|
+
};
|
|
54
|
+
if (!Array.isArray(result_data.data)) result_data.data = [result_data.data];
|
|
55
|
+
if (props.allowChildRows) result_data.data = (0, _helpers.fix_parent_child_relations)(result_data.data);
|
|
56
|
+
if (!result_data.count) result_data.count = result_data.data.length;
|
|
57
|
+
return result_data;
|
|
65
58
|
}, [props.dataSource]);
|
|
66
59
|
return _react.default.createElement(DataGrid, {
|
|
67
60
|
...props,
|
package/package.json
CHANGED
package/src/views/DataGrid.tsx
CHANGED
|
@@ -134,23 +134,21 @@ export function AzGrid(props: AzGridProps) {
|
|
|
134
134
|
/* -------------------------------------------------------------------------- */
|
|
135
135
|
const dataSource = React.useCallback(
|
|
136
136
|
async (dt) => {
|
|
137
|
-
let result_rows: any[] = [];
|
|
138
137
|
let result_data: any = undefined;
|
|
139
138
|
if (typeof props.dataSource === 'function') {
|
|
140
139
|
result_data = await props.dataSource(dt);
|
|
141
|
-
if (typeof result_data === 'object') {
|
|
142
|
-
result_rows = result_data.data;
|
|
143
|
-
} else result_rows = result_data;
|
|
144
|
-
} else {
|
|
145
|
-
result_rows = props.dataSource || [];
|
|
146
140
|
}
|
|
147
|
-
if (!
|
|
148
|
-
if (props.allowChildRows) result_rows = fix_parent_child_relations(result_rows);
|
|
141
|
+
if (!result_data) result_data = [];
|
|
149
142
|
|
|
150
|
-
if (result_data
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
143
|
+
if (Array.isArray(result_data) || typeof result_data !== 'object')
|
|
144
|
+
result_data = { data: result_data };
|
|
145
|
+
|
|
146
|
+
if (!Array.isArray(result_data.data)) result_data.data = [result_data.data];
|
|
147
|
+
if (props.allowChildRows)
|
|
148
|
+
result_data.data = fix_parent_child_relations(result_data.data);
|
|
149
|
+
if (!result_data.count) result_data.count = (result_data.data as Array<any>).length;
|
|
150
|
+
|
|
151
|
+
return result_data;
|
|
154
152
|
},
|
|
155
153
|
[props.dataSource]
|
|
156
154
|
);
|