Data Display
DataGrid
A bounded grid with explicit column order, visibility and pinning.
import { DataGrid } from 'faifo-design'DataGrid shows wide tabular data with pinned columns and a set of visible columns chosen by the
reader. Row rendering is capped, so a large result stays responsive before virtualization is needed.
#When to use
- Use it for analytical tables with many columns.
- Use
DataTablefor ordinary collections andFaifoGridfor editing.
#Examples
Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.
#Bounded data grid
Column order, visibility and pinning are explicit; row rendering is capped before virtualization.
| Order | Customer | Total | State |
|---|---|---|---|
| SO-1042 | Công ty Ánh Dương | 18.450.000 ₫ | Ready |
| SO-1041 | Khách sạn Mùa Hạ | 6.800.000 ₫ | Review |
| SO-1039 | Nguyễn Minh Châu | 2.150.000 ₫ | Blocked |
Show codeHide code
import { DataGrid } from 'faifo-design'
type OrderRow = {
id: string
customer: string
total: string
state: 'Ready' | 'Review' | 'Blocked'
}
const orders: OrderRow[] = [
{ id: 'SO-1042', customer: 'Công ty Ánh Dương', total: '18.450.000 ₫', state: 'Ready' },
{ id: 'SO-1041', customer: 'Khách sạn Mùa Hạ', total: '6.800.000 ₫', state: 'Review' },
{ id: 'SO-1039', customer: 'Nguyễn Minh Châu', total: '2.150.000 ₫', state: 'Blocked' },
]
export const Example = () => (
<DataGrid
label="Order analysis"
rows={orders}
id={(row) => row.id}
maxRows={500}
columns={[
{ key: 'id', label: 'Order', cell: (row) => row.id, pinned: 'start', width: '8rem' },
{ key: 'customer', label: 'Customer', cell: (row) => row.customer, width: '18rem' },
{ key: 'total', label: 'Total', cell: (row) => row.total, width: '10rem' },
{ key: 'state', label: 'State', cell: (row) => row.state, width: '9rem' },
]}
/>
)#API
Generated from the package source. A property without a description has none in the source yet.
#DataGridComponent
| Property | Description | Type | Default |
|---|---|---|---|
labelrequired | – | string | – |
rowsrequired | – | readonly Row[] | – |
idrequired | – | (row: Row) => string | – |
columnsrequired | – | readonly DataGridColumn<Row>[] | – |
columnOrder | – | readonly string[] | – |
maxRows | – | number | 500 |
capLabel | – | (shown: number, total: number) => string | – |
density | – | 'compact' | 'default' | 'comfortable' | 'default' |
#Types
#DataGridColumn
| Property | Description | Type | Default |
|---|---|---|---|
keyrequired | – | string | – |
labelrequired | – | string | – |
cellrequired | – | (row: Row) => JSXChild | – |
visible | – | boolean | – |
pinned | – | 'start' | 'end' | – |
width | – | string | – |
#DataGridProps
The properties of DataGrid, listed above.
#Hooks
The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.
data-grid-scrolldata-griddata-grid-capdata-grid-cell