This project uses the core TanStack Table library (@tanstack/table-core) rather than the React wrapper. The table setup is spread across the following files:
src/main.jssrc/table/features.jssrc/table/columns.jssrc/table/filters.jssrc/ui/table.js
Used in src/main.js.
Creates the actual table instance from:
columnsdatafeaturesinitialState
This is the main table engine that manages state and behavior.
Defined in src/table/features.js.
This registers the features the table supports. In this app, it enables:
- sorting
- filtering
- pagination
- store reactivity
Imported from @tanstack/table-core/store-reactivity-bindings.
This keeps the table state reactive. Because of it, the app can subscribe to table-store changes and re-render the table whenever filters, sort state, or pagination changes.
Enabled in src/table/features.js.
Adds sort support for rows. When a user clicks a column header, the table toggles sorting for that column and reorders the rows.
The click handler is wired in src/ui/table.js using:
header.column.getToggleSortingHandler()
Enabled in src/table/features.js.
Adds filter support to columns. In this final version, the filter row is no longer rendered in the UI because the app uses a request panel and a response-driven table instead of inline text filters.
The filtering support remains available in the feature set, but the current interface does not expose it visually.
Used in src/table/features.js.
This is the built-in string filter function. It is assigned to most of the columns, such as:
idfirstNamelastNameageemail
It checks whether the cell value contains the text typed by the user.
Defined in src/table/filters.js.
This custom filter handles the gender column, which is not a plain text search. It supports:
both→ show all rowsmale→ show only male rowsfemale→ show only female rows
This is assigned to the gender column in src/table/columns.js.
Enabled in src/table/features.js.
Adds pagination support. The table keeps track of which page is active and only shows a subset of rows at a time.
The app sets:
pageIndex: 0pageSize: 8
in src/main.js.
Defined in src/table/columns.js.
Each column includes:
accessorKey: the row property to readheader: visible column labelcell: how the value is renderedfilterFn: which filter logic to use
Current active columns include:
nameassetValuesoldsaleValueprofitValueprofitPercentage
The older user-based columns are kept only as commented examples in src/table/columns.js and are not active in the rendered table.
Imported from @tanstack/table-core/flex-render.
Used in src/ui/table.js to render table cells and headers cleanly. It helps TanStack output values in the DOM without hardcoded assumptions about the structure.
These are the exact TanStack API calls used inside src/ui/table.js:
table.getHeaderGroups()- Returns the grouped header model from TanStack so the app can render the header row and filter row.
table.getRowModel().rows- Returns the current filtered/sorted/paginated rows.
table.getCanPreviousPage()- Tells the UI whether the previous-page button should be enabled.
table.getCanNextPage()- Tells the UI whether the next-page button should be enabled.
table.previousPage()/table.nextPage()- TanStack pagination actions that move the current page index.
table.store.subscribe(...)- Subscribes to table state updates so rendering happens whenever state changes.
table.store.state.pagination.pageIndex- Reads the current pagination state from TanStack’s internal store.
On each column, these TanStack methods are used:
header.column.getToggleSortingHandler()- Activates the sort toggle when the header is clicked.
header.column.getIsSorted()- Reads the current sort direction for the column.
header.column.getFilterValue()- Reads the current filter value for that column when filters are enabled.
header.column.setFilterValue(value)- Updates the filter value in TanStack state when filters are enabled.
This is the key point: the code is not using plain DOM table logic. It is using TanStack's table state and model, then converting that into HTML in the browser.
These are all the TanStack table pieces actually used in the app:
constructTable(...)- Creates the table instance from columns, data, features, and initial state.
table.store.subscribe(...)- Reacts to updates in the table store.
table.store.state.pagination.pageIndex- Reads the current page index from TanStack state.
tableFeatures(...)- Registers enabled features.
storeReactivityBindings()- Makes table state reactive.
rowSortingFeature- Enables row sorting.
columnFilteringFeature- Enables column filtering.
rowPaginationFeature- Enables pagination.
createSortedRowModel()- Produces the sorted row model.
createFilteredRowModel()- Produces the filtered row model.
createPaginatedRowModel()- Produces the paginated row model.
filterFn_includesString- Built-in string match filter used by most text columns.
genderFilterFn- Custom custom filter for the gender column.
filterFns: { includesString: ... }- Registers the custom filter name used in column definitions.
accessorKey- Tells TanStack which field to read from each row.
header- Display title for the column.
cell- Renderer for each value.
cell: (info) => info.getValue()- Common pattern used to output the underlying value from a cell.
filterFn- Which filter behavior should apply to that column.
table.getHeaderGroups()- Gets the grouped header model.
header.isPlaceholder- Indicates whether a header cell is a placeholder.
header.column.id- Column id used to identify the column.
header.column.getToggleSortingHandler()- Sort toggle handler for header clicks.
header.column.getIsSorted()- Returns the current sort direction for the column (
asc,desc, or false).
- Returns the current sort direction for the column (
header.column.getFilterValue()- Reads the active filter value for that column when filtering is used.
header.column.setFilterValue(value)- Updates the filter value in TanStack state when filtering is used.
table.getRowModel().rows- Gets the visible rows after sorting/filtering/pagination.
row.getAllCells()- Gets all cells in a given row.
cell.getValue()/info.getValue()- Reads the raw value from the current cell or column cell context.
row.getValue(columnId)- Reads a value from a row by column id, used in the custom gender filter and older examples.
table.getCanPreviousPage()- Checks whether previous page is available.
table.getCanNextPage()- Checks whether next page is available.
table.previousPage()- Moves to the previous page.
table.nextPage()- Moves to the next page.
initialState: { pagination: { pageIndex, pageSize } }- Sets the starting pagination state.
This app uses TanStack Table for:
- rendering rows and columns
- sorting by clicking headers
- pagination
- reactive state updates
- DOM rendering via custom UI code
- receiving data from the request panel and rendering it in table form
The current active columns are name, assetValue, sold, saleValue, profitValue, and profitPercentage.
The older user-based columns remain only as commented examples and are not part of the active rendered table.
In short, TanStack Table is acting as the table engine and state manager, while the project’s custom JavaScript is handling the browser rendering and the API-driven dataset updates.