DataView
A table and card grid with search, row click, and cursor pagination.
When to use
Use DataView when you need a table and card grid with search, row click, and cursor pagination.
Import
import { DataView } from '@gzodo/ui'DataView fills its parent. Give the parent a height. The header holds a title, an optional controlled search field, and a table/grid toggle. Search does not filter rows itself: update data from search.onChange. Pagination appears when limit, totalCount, and totalPages are all set. The footer walks cursors with setCursor.
Examples
4Ada Lovelace
Table
isRecordDisabled returns true. Search narrows the list you pass in.Directory
Page 1 of 3
1 - 2 of 6
Pagination
cursor, limit, nextCursor, totalCount, totalPages, and setCursor. Previous and next walk that cursor.Cards
Ada Lovelace
Admin · Active
Grace Hopper
Engineer · Active
Alan Turing
Research · Away
Katherine Johnson
Analyst · Active
Margaret Hamilton
Engineer · Away
Tim Berners-Lee
Admin · Invited
Grid
defaultView="grid" starts there. renderRecord replaces the default field list.Team
Loading...
Team
Nothing matched this filter.
Loading and empty
isLoading replaces the body with “Loading...”. An empty data array shows “No data”, or noData when you pass it.DataView
14DataView
titleReactNodecolumnsDataViewColumn<T>[]dataT[]search{ value: string; onChange: (value: string) => void }onClickRow(record: T) => voidisRecordDisabled(record: T) => booleanrenderRecord(record: T) => ReactNodedefaultView'table' | 'grid''table'paginationDataViewPaginationisLoadingbooleanheaderReactNodeghostbooleannoDataReactNodeclassNamestringDataViewColumn
5DataViewColumn
titlestringdataIndexkeyof Trender(value, record: T) => ReactNodewidthstringjustify'flex-start' | 'center' | 'flex-end'DataViewPagination
6DataViewPagination
cursorstring | nulllimitnumbernextCursorstring | nulltotalCountnumbertotalPagesnumbersetCursor(cursor: string | null) => void