fix: update column handling in TableList to support function-based column definitions

This commit is contained in:
faisolavolut 2025-04-28 11:46:57 +07:00
parent c04631519f
commit 246b1a80fe
1 changed files with 6 additions and 4 deletions

View File

@ -323,13 +323,14 @@ export const TableList = <T extends object>({
}; };
useEffect(() => { useEffect(() => {
try { try {
if (Array.isArray(column) && column?.length) { const col = typeof column === "function" ? column() : column;
const dateIndices = Array.isArray(column) if (Array.isArray(col) && col?.length) {
? column const dateIndices = Array.isArray(col)
? col
.map((e, index) => (e.type === "date" ? index : -1)) .map((e, index) => (e.type === "date" ? index : -1))
.filter((index) => index !== -1) .filter((index) => index !== -1)
: []; : [];
const result: FieldFilterProps[] = column const result: FieldFilterProps[] = col
.filter( .filter(
(e, index) => (e, index) =>
e.filter !== false && e.filter !== false &&
@ -362,6 +363,7 @@ export const TableList = <T extends object>({
pagination: e?.pagination, pagination: e?.pagination,
search: e?.search, search: e?.search,
})); }));
console.log({ result });
local.fieldFilter = result; local.fieldFilter = result;
local.render(); local.render();
} }