These are the props of ka-table 13. In TypeScript the type of the rows (TData) is inferred from data; the values of the cells and the keys of the rows are unknown.

Table

The props of the Table component, grouped by feature. Only columns, data and rowKeyField are required.

Data and columns

Name Type Description
columns Column[] Columns in table and their look and behaviour
data TData[] The Table’s data. Change it immutably: the data is processed again when the reference changes
rowKeyField string Data’s field which is used to identify row
format (props: { value: unknown, column: Column, rowData?: TData; }) => ReactNode Returns the content of the cell; undefined, null and false show the value itself. The search, the groups and the header filter use its text (Demo: Custom Cell)
groupedColumns GroupedColumn[] (Demo: Grouped Columns)
columnReordering boolean Enables columns reordering using drag and drop
columnResizing boolean The columns are resized by the mouse. While a column is resized, the rows are not processed and rendered again: they don’t use the widths, and they are rendered with the new width when the mouse is released. A controlled table doesn’t render the rows only if the props which the parent passes keep their references between its renders (dispatch, childComponents, format…), as with memoizedRows (Demo: Column Resizing)
rowReordering boolean Enables rows reordering using drag and drop

Sorting

Name Type Description
sortingMode 'none'
'single'
'singleTripleState'
'singleRemote'
'singleTripleStateRemote'
'multipleRemote'
'multipleTripleStateRemote'
Sorting mode.
Remote - means only grid elements are updated but data should be sorted outside of the grid.
TripleState - means: “ascend - descend - no sorting” (Demo: Sorting Example)
sort (props: { column: Column }) => ((valueA: unknown, valueB: unknown, rowDataA: TData, rowDataB: TData) => number) | void Returns the comparator of the sorted column, as the one of Array.prototype.sort: e.g. Intl.Collator().compare or (a, b) => a - b. It sorts in the direction of the column (Demo: Sorting Custom Logic)
extendedSort (data: TData[], columns: Column[]) => TData[] Sorts the data instead of the default sorting (Demo: Sorting Extended)
Name Type Description
filteringMode 'none'
'filterRow'
'headerFilter'
'filterRowAndHeaderFilter'
Show filter UI elements in Table (Demo: Filter Row Example)
filter (props: { column: Column }) => ((value: unknown, filterRowValue: unknown, rowData?: TData) => boolean) | void Returns filter function
extendedFilter (data: TData[]) => TData[] Adds additional filtering layer (Demo: Filter Extended)
searchText string Specifies the text for search by data: the text which the cells of the visible columns show is searched (Demo: Search Example)
search (props: { searchText: string, rowData: TData, column: Column }) => boolean | void Overrides the default search method for the cell, undefined keeps the default search of the column. Executes if searchText is set

Editing

Name Type Description
editingMode 'none'
'cell'
Sets the table’s editing mode
note: when EditingMode.Cell is enabled table calls CloseEditor action each time editor loses focus (Demo: Editing Example)
editableCells EditableCell[] Array of cells currently editing (Demo: Editing Example)
validation (props: { value: unknown, rowData: TData, column: Column }) => string | void Returns the validation error string or does not return anything in case of passed validation; rowData has the edited values of the row (Demo: Validation Example)

Grouping and tree

Name Type Description
groups Group[] Groups in the table (Demo: Grouping Example)
groupsExpanded unknown[][] Expanded groups - array of group keys
groupPanel {
enabled?: boolean;
text?: string;
deep?: number;
}
Allows users to select grouping columns in the UI. (Demo: Grouping)
treeGroupKeyField string Group key field (Demo: Tree Mode)
treeGroupsExpanded unknown[] Array of ids of expanded rows, if it is undefined - all rows are expanded (Demo: Tree Mode)
treeExpandButtonColumnKey string Sets the column key where tree expanded button will be rendered, by default it is rendered in the first column of the table

Paging and virtual scrolling

Name Type Description
paging {
enabled?: boolean;
pageIndex?: number;
pageSize?: number;
pageSizes?: number[];
pagesCount?: number;
position?: ('bottom' | 'top' | 'topAndBottom');
}
Paging settings, pagesCount is set for remote paging (Demo: Paging)
virtualScrolling VirtualScrolling Virtual scrolling options of the rows and the columns (Demo: Many Rows Example, Many Columns)
memoizedRows boolean Rows and their cells are re-rendered only when their own props change, which is much faster for big tables. Customizations of rows and cells (childComponents) have to render from their props then: values read from table.props or from closures during rendering are not updated. childComponents, format, validation and dispatch should keep their references between renders (be declared outside of the component or memoized), otherwise all the rows are re-rendered. (Demo: 300K Rows & memo)

Selection, details rows and focus

Name Type Description
selectedRows unknown[] Array of selected rows keys (Demo: Selection Example)
detailsRows unknown[] Keys of the rows whose details rows are shown (Demo: Details Row)
focused {
cell?: { columnKey: string; rowKeyValue: unknown; };
cellEditorInput?: { columnKey: string; rowKeyValue: unknown; };
group?: unknown[];
}
Stores information about the currently focused element: the cell or the group row (its key) focused by the keyboard navigation (Demo: Keyboard navigation)
keyboardNavigation boolean Navigation by the cells with the keyboard (the grid pattern of WAI-ARIA, treegrid for a tree), enabled by default: the table is a single stop of Tab, arrows move the focus between the cells (with Ctrl to the last one), Home and End to the first and the last cell of the row (with Ctrl of the page), PageUp and PageDown change the page, Enter and F2 open the editor. Group rows get the focus as rows: Enter, Space and the arrows Left and Right expand and collapse them. Enter and Space on the cell of the arrow of a tree row expand and collapse it (F2 opens the editor of this cell). The focus is kept in focused.cell (focused.group for a group row). false turns the navigation off, e.g. for an own handling of the keys. (Demo: Keyboard navigation)

Appearance

Name Type Description
childComponents ChildComponents Customization logic for ka-table parts (cells, rows, editors, etc.) (Demo: Events, Custom Cell)
height number | string Height of the component
width number | string Width of the component
loading {
enabled?: boolean;
text?: string;
}
Loading indicator options (Demo: Loading)
noData {
text?: string;
hideHeader?: boolean;
}
No data settings (for deeper UI customization childComponents.noDataRow also) (Demo: Search)
oddEvenRows boolean | 'treeRoots' The rows get the classes ka-odd and ka-even in turn, counted from the first row of the page, also with the virtual scrolling. 'treeRoots': a root of a tree and all its children get the class of the root, the stripes change at the roots only (Demo: 100K Rows)

State

Name Type Description
dispatch (action: TableAction | CustomAction) => void The function takes action as an argument, is used as a notification about any changes and events in the Table. dispatch enables controlled mode in the table
table ITableInstance Object is used only by uncontrolled mode to get/set table props, use useTable() to create your own instance and handle changes using onDispatch, and use useTableInstance() to get instance of table from context
controlledPropsKeys (keyof ITableProps)[] The props which the table with its own state (without dispatch) applies when the parent changes them. By default these are all the props: they are compared by value and the objects are merged by the changed fields, so the state of the table (sorting, page, widths…) is kept when the parent passes equal props again. During a loading (loading.enabled) data, columns, paging and selectedRows are applied when the loading ends. The functions (format, filter, search, sort, validation…) are not the state: the latest ones are always used.
singleAction TableAction | CustomAction Is dispatched only once after Table render, after this action ka-table will dispatch 'ClearSingleAction' to set singleAction as undefined (Demo: Remote Data)

Column

Name Type Description
colGroup ColHTMLAttributes<HTMLElement> Sets attributes for col element in table colGroup
dataType 'boolean'
'date'
'number'
'object'
'string'
Specifies the type of column
filter (value: unknown, filterValue: unknown, rowData?: TData) => boolean Returns filter function for particular column (Demo: Filter Custom Logic)
filterRowOperator string Sets filter row operator. Predefined filter operators are: '=', '!=', '>', '<', '>=', '<=', 'contains', 'IsEmpty', 'IsNotEmpty' (Demo: Filter Row Custom Editor)
filterRowValue unknown Sets filter row value (Demo: Filter Row)
field string Specifies the property of data’s object which value will be used in column, if null value from key option will be used
fixed 'left' | 'right' The column sticks to the edge of the table when it is scrolled horizontally, after the other fixed columns of the edge. The offsets are calculated from the numeric width of the fixed columns. The horizontal virtual scrolling always renders the fixed columns (Demo: Fixed Column)
headerFilterListItems (props: { data?: TData[] }) => string[] Returns array of header filter items (Demo: Header Filter - Logic)
headerFilterSearch (value: string, searchValue: string, rowData?: HeaderFilterItem) => boolean Used to customize header filter search logic, HeaderFilterItem is { value: string, isSelected: boolean } (Demo: Header Filter - Logic)
headerFilterSearchValue string Stores value for search by headerFilterValues (Demo: Header Filter - Logic)
headerFilterValues string[] Array of selected values
headerFilterPopupPosition {
x?: number;
y?: number;
}
Header filter popup position
isDraggable boolean Specifies can a column be dragged or not
isEditable boolean Specifies can a column be editable or not
isFilterable boolean If false then header filter cell content will not be shown for a column
isHeaderFilterPopupShown boolean Shows/hides header filter popup for specific column
isHeaderFilterSearchable boolean Enables search in header filter
isResizable boolean Specifies can a column be resized or not (Demo: Column Resizing)
isSortable boolean Specifies can a column be sorted or not (Demo: Sorting)
key string Mandatory field, specifies unique key for the column
sortDirection 'ascend'
'descend'
Sets the direction of sorting for the column (Demo: Sorting)
sortIndex number The priority of the column for sorting (Demo: Sorting)
style CSSProperties Sets the style options of the elements
title string Specifies the text of the header
visible boolean Shows/Hides columns
width number | string Column width. A number (pixels) is required for fixed offsets and for virtualScrolling.horizontal

EditableCell

Describes the editor of a cell in the table

Name Type Description
columnKey string The key of specific column
rowKeyValue unknown Data’s key value of every specific row
editorValue unknown Value of the editor
validationMessage string Validation message of the column

Group

Name Type Description
columnKey string The key of the grouped column
enableSummary boolean Enable summary row for the group
enabled boolean false keeps the settings of the group without grouping the rows: the group is enabled when its column is grouped (e.g. dropped on the group panel). Ungrouping disables a group with settings instead of removing it
Skip such groups in the code which reads groups

GroupedColumn

Demo: Grouped Columns

Name Type Description
key string Unique identifier
title string Used to show text in the cell
columnsKeys string[] List of children’s keys

VirtualScrolling

Properties

Name Type Description
enabled boolean Enables virtual scrolling: only the visible rows are rendered. false shows all the rows
scrollTop number Current scroll top position (the state of the table)
itemHeight ((data: unknown) => number) | number The height of the rows, or a function which returns the height of a row of the shown data: a row of the data, a group row, a tree row…
tbodyHeight number Tbody height
topInvisibleCount number Amount of rows which should be rendered over visible area (useful for scrolling - in that case some items will be already visible and it will be more smooth)
bottomInvisibleCount number Amount of rows which should be rendered under visible area
horizontal boolean The columns are virtualized too: only the visible columns are rendered, and the fixed ones and the ones without a numeric width; spacers keep the width of the table. Is not applied with groupedColumns (Demo: Many Columns)
scrollLeft number Horizontal: scroll left position at the last change of the rendered columns (the state of the table)
tableWidth number Horizontal: the width of the visible part of the table, measured when it is not set
leftInvisibleCount number Horizontal: amount of columns rendered before the visible ones (2 by default)
rightInvisibleCount number Horizontal: amount of columns rendered after the visible ones (2 by default)

You can set VirtualScrolling as empty object {} to enable virtual scrolling and auto calculate its parameters. The table needs its own scrolling: limit its height, e.g. childComponents.tableWrapper with style: { maxHeight: 600 }.

// 2 000 rows of 500 columns: only the visible rows and columns are rendered
const virtualScrolling = { enabled: true, horizontal: true };
// the table is scrolled inside its wrapper
const childComponents = {
  tableWrapper: {
    elementAttributes: () => ({ style: { maxHeight: 600 } }),
  },
};

<Table
  columns={columns} // every column has a numeric width
  data={data}
  rowKeyField={'id'}
  virtualScrolling={virtualScrolling}
  childComponents={childComponents}
/>

See also

  • ChildComponents: the customization of the parts of the table.
  • Hooks and Utils: useTable(), useTableInstance(), useTableSelector(), kaPropsUtils, kaDateUtils and kaPagingUtils.