Updated Table Component
This commit is contained in:
@@ -18,6 +18,7 @@ const {
|
|||||||
tableClassNames = "",
|
tableClassNames = "",
|
||||||
hideHeader = false,
|
hideHeader = false,
|
||||||
rowClick = "",
|
rowClick = "",
|
||||||
|
defaultSort = {},
|
||||||
} = Astro.props as TableProps<any>;
|
} = Astro.props as TableProps<any>;
|
||||||
|
|
||||||
const id = `table-${Math.random().toString(36).slice(2, 9)}`;
|
const id = `table-${Math.random().toString(36).slice(2, 9)}`;
|
||||||
@@ -155,6 +156,7 @@ const id = `table-${Math.random().toString(36).slice(2, 9)}`;
|
|||||||
columnsRendererKey,
|
columnsRendererKey,
|
||||||
classInfos,
|
classInfos,
|
||||||
rowClick,
|
rowClick,
|
||||||
|
defaultSort,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
const start = () => {
|
const start = () => {
|
||||||
@@ -173,7 +175,7 @@ const id = `table-${Math.random().toString(36).slice(2, 9)}`;
|
|||||||
let rowsPerPage = pagignations
|
let rowsPerPage = pagignations
|
||||||
? parseInt(pageSizeSelector.value)
|
? parseInt(pageSizeSelector.value)
|
||||||
: 9999;
|
: 9999;
|
||||||
let sort = {}; // { key: "asc" | "desc" }
|
let sort = defaultSort; // { key: "asc" | "desc" }
|
||||||
let totalRows = data.length;
|
let totalRows = data.length;
|
||||||
let currentData = [...data];
|
let currentData = [...data];
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export interface TableProps<T> {
|
|||||||
tableClassNames?: string;
|
tableClassNames?: string;
|
||||||
hideHeader?: boolean;
|
hideHeader?: boolean;
|
||||||
rowClick?: string;
|
rowClick?: string;
|
||||||
|
defaultSort?: Record<string, string>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Sort = {
|
export type Sort = {
|
||||||
|
|||||||
Reference in New Issue
Block a user