feat: add error handling to onCount function and ensure local count is set correctly
This commit is contained in:
parent
09fc4af459
commit
d7682b47ba
|
|
@ -238,11 +238,13 @@ export const TableList: React.FC<any> = ({
|
||||||
{"Loading..."}
|
{"Loading..."}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
try {
|
||||||
if (typeof onCount === "function") {
|
if (typeof onCount === "function") {
|
||||||
const res = await onCount();
|
const res = await onCount();
|
||||||
local.count = res;
|
local.count = res;
|
||||||
local.render();
|
local.render();
|
||||||
}
|
}
|
||||||
|
} catch (ex) {}
|
||||||
if (mode === "form") {
|
if (mode === "form") {
|
||||||
local.data = fm.data?.[name] || [];
|
local.data = fm.data?.[name] || [];
|
||||||
cloneListFM(fm.data?.[name] || []);
|
cloneListFM(fm.data?.[name] || []);
|
||||||
|
|
@ -264,6 +266,9 @@ export const TableList: React.FC<any> = ({
|
||||||
if (!autoPagination) {
|
if (!autoPagination) {
|
||||||
res = paginateArray(res, take, 1);
|
res = paginateArray(res, take, 1);
|
||||||
}
|
}
|
||||||
|
if (!local.count) {
|
||||||
|
local.count = res?.length;
|
||||||
|
}
|
||||||
local.data = res;
|
local.data = res;
|
||||||
if (mode === "form") cloneListFM(res);
|
if (mode === "form") cloneListFM(res);
|
||||||
local.render();
|
local.render();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue