Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sticky headers #9022

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/backend/InvenTree/common/setting/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def label_printer_options():
'default': False,
'validator': bool,
},
'STICKY_TABLE_HEADER': {
'name': _('Fixed Table Headers'),
'description': _('Table headers are fixed to the top of the table'),
'default': False,
'validator': bool,
},
'DATE_DISPLAY_FORMAT': {
'name': _('Date Format'),
'description': _('Preferred format for displaying dates'),
Expand Down
1 change: 1 addition & 0 deletions src/frontend/src/pages/Index/Settings/UserSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export default function UserSettings() {
<UserSettingList
keys={[
'STICKY_HEADER',
'STICKY_TABLE_HEADER',
'DATE_DISPLAY_FORMAT',
'FORMS_CLOSE_USING_ESCAPE',
'PART_SHOW_QUANTITY_IN_FORMS',
Expand Down
9 changes: 9 additions & 0 deletions src/frontend/src/tables/InvenTreeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { navigateToLink } from '../functions/navigation';
import { getDetailUrl } from '../functions/urls';
import type { TableState } from '../hooks/UseTable';
import { useLocalState } from '../states/LocalState';
import { useUserSettingsState } from '../states/SettingsState';
import type { TableColumn } from './Column';
import type { TableFilter } from './Filter';
import InvenTreeTableHeader from './InvenTreeTableHeader';
Expand Down Expand Up @@ -143,6 +144,12 @@ export function InvenTreeTable<T extends Record<string, any>>({
const navigate = useNavigate();
const { showContextMenu } = useContextMenu();

const userSettings = useUserSettingsState();

const stickyTableHeader = useMemo(() => {
return userSettings.isSet('STICKY_TABLE_HEADER');
}, [userSettings]);

// Construct table filters - note that we can introspect filter labels from column names
const filters: TableFilter[] = useMemo(() => {
return (
Expand Down Expand Up @@ -707,6 +714,8 @@ export function InvenTreeTable<T extends Record<string, any>>({
<Boundary label={`InvenTreeTable-${tableState.tableKey}`}>
<Box pos='relative'>
<DataTable
stickyHeader={stickyTableHeader}
height={stickyTableHeader ? 600 : undefined}
withTableBorder={!tableProps.noHeader}
withColumnBorders
striped
Expand Down
Loading