Table borders (#7957)

* Add 'editable' attribute to table column type

* Add "editable" attribute for useTable hook

* Add column borders to tables
This commit is contained in:
Oliver 2024-08-22 16:08:41 +10:00 committed by GitHub
parent ca87df3c3d
commit 1dff94db75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -39,6 +39,8 @@ export type TableState = {
records: any[];
setRecords: (records: any[]) => void;
updateRecord: (record: any) => void;
editable: boolean;
setEditable: (value: boolean) => void;
};
/**
@ -131,6 +133,8 @@ export function useTable(tableName: string): TableState {
const [isLoading, setIsLoading] = useState<boolean>(false);
const [editable, setEditable] = useState<boolean>(false);
return {
tableKey,
refreshTable,
@ -156,6 +160,8 @@ export function useTable(tableName: string): TableState {
setPage,
records,
setRecords,
updateRecord
updateRecord,
editable,
setEditable
};
}

View File

@ -1,3 +1,5 @@
import { ApiFormFieldType } from '../components/forms/fields/ApiFormField';
export type TableColumnProps<T = any> = {
accessor?: string; // The key in the record to access
title?: string; // The title of the column - Note: this may be supplied by the API, and is not required, but it can be overridden if required
@ -5,6 +7,8 @@ export type TableColumnProps<T = any> = {
sortable?: boolean; // Whether the column is sortable
switchable?: boolean; // Whether the column is switchable
hidden?: boolean; // Whether the column is hidden
editable?: boolean; // Whether the value of this column can be edited
definition?: ApiFormFieldType; // Optional field definition for the column
render?: (record: T, index?: number) => any; // A custom render function
filter?: any; // A custom filter function
filtering?: boolean; // Whether the column is filterable

View File

@ -697,6 +697,7 @@ export function InvenTreeTable<T = any>({
<DataTable
withTableBorder
withColumnBorders
striped
highlightOnHover
loaderType="dots"