Skip to content

Column options ​

ts
import type { ColumnConfig } from "@datagrid/vue-ui";

const columns: Array<ColumnConfig<Person>> = [{ field: "name", sortable: true }];

Callback parameters (params) contain value, data (the row data), item (the row object) and column.

Identification & header ​

OptionTypeDescription
fieldstringproperty of the row data, nested with dots ("address.city")
idstringunique id, default field
textstringheader text
typestring | string[]"text", "number", "date", "boolean" or custom types
childrenColumnConfig[]columns of a column group
headerTooltipstringtooltip of the header
metaanyyour own data

Size & layout ​

OptionTypeDefaultDescription
widthnumber100width in px
minWidth / maxWidthnumber–
flexnumber–share of the free space
autosizebooleanfalsewidth from the content
autosizeAdjust(column, widths) => number–adjust the autosized width
autoHeightbooleanfalsetext wraps, rows grow
pinned"left" | "right"–pinned column
visiblebooleantrue

Features ​

OptionTypeDefaultDescription
sortablebooleanfalse
filterablebooleanfalse
resizeablebooleanfalse
moveablebooleanfalse
groupablebooleanfalse
editableboolean | (params) => booleanfalse
menubooleangrid option columnMenucolumn menu button
rowDragboolean | (params) => booleanfalsedrag handle to drag rows
cellSelectableboolean | (params) => booleantruefor cell selection
cellFocusableboolean | (params) => booleantrue

Values ​

OptionTypeDescription
valueGetter(params) => valuecomputed value
valueFormatter(params) => stringdisplayed text, see formatters
valueSetter(params) => void | booleanwrites an edited value, return false if nothing changed
valueParser({ value, oldValue, item, column }) => valueconverts input to the column type

Sorting ​

OptionTypeDescription
sort"asc" | "desc"initial sort
sortingOrder("asc" | "desc" | null)[]order when clicking
sortFunc(a, b) => numbercomparator, a / b contain value and item

Filtering ​

OptionTypeDescription
filterType"text" | "number" | "date" | "set" | "boolean"default depends on type
filterParams{ operators?, values?, debounce? }see options
filter(value, filterValue, row) => booleancustom filter function
filterComponentComponentcustom floating filter; Vue: props modelValue, column, emits update:modelValue; React: props value, onChange, column

Editing ​

OptionTypeDescription
editor"text" | "textarea" | "number" | "date" | "select" | "checkbox"built-in editor
editorParams{ options?, placeholder?, min?, max?, step? }parameters of the editor
editComponentComponentcustom editor, see custom editors

Aggregation ​

OptionTypeDescription
aggFunc"sum" | "avg" | "min" | "max" | "count" | "first" | "last" | (values, rows) => anyaggregation for group rows and the total row

Rendering ​

OptionTypeDescription
align"left" | "center" | "right" | (params) => alignmentcell alignment
headerAlign"left" | "center" | "right"header alignment
cellClassstring | string[] | (params) => string | string[]
cellStylestyle | (params) => style
headerCellClassstring | string[] | ({ column }) => …
headerCellStylestyle | ({ column }) => style
tooltipboolean | (params) => stringcell tooltip
flashOnChangebooleanhighlights the cell when its value changes (green/red for numbers)
componentComponentcell component
componentPropsobject | (params) => objectadditional props of the cell component
headerComponentComponentheader component (text, column)

Released under the ISC License.