From 3b93f60012b4a630b03c4efe077a646eb973c531 Mon Sep 17 00:00:00 2001 From: Ajay Ghanwat Date: Fri, 14 Nov 2025 22:58:47 +0530 Subject: [PATCH] New Changes with Column Type --- src/components/Table.astro | 6 ++++-- src/pages/table.astro | 2 ++ src/types/table/types.ts | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Table.astro b/src/components/Table.astro index b423151..d6757be 100644 --- a/src/components/Table.astro +++ b/src/components/Table.astro @@ -302,7 +302,8 @@ const id = `table-${Math.random().toString(36).slice(2, 9)}`; .join(" ")}">`; columns.forEach((col, colIndex) => { - let value = row[col.key] ?? ""; + let data = col.path ? row[col.path] : row; + let value = data[col.key] ?? ""; const renderers = columnsRendererKey ? window[columnsRendererKey] @@ -346,7 +347,8 @@ const id = `table-${Math.random().toString(36).slice(2, 9)}`; // 📱 Mobile let card = `
`; columns.forEach((col, colIndex) => { - let value = row[col.key] ?? ""; + let data = col.path ? row[col.path] : row; + let value = data[col.key] ?? ""; const renderers = columnsRendererKey ? window[columnsRendererKey] diff --git a/src/pages/table.astro b/src/pages/table.astro index fdedf8c..38edb20 100644 --- a/src/pages/table.astro +++ b/src/pages/table.astro @@ -298,6 +298,8 @@ const studentColumns = [ "button[id^='view-'], button[id^='edit-'], button[id^='delete-']", ); + console.log(buttons); + buttons.forEach((button) => { const id = button.getAttribute("data-id"); diff --git a/src/types/table/types.ts b/src/types/table/types.ts index ce856b0..495f736 100644 --- a/src/types/table/types.ts +++ b/src/types/table/types.ts @@ -14,6 +14,7 @@ export type ClassNames = { export interface Column { key: keyof T | string; label: string; + path?: string; sortable?: boolean; searchable?: boolean; render?: (value: any, row: T) => string;