0.2.4 • Published 4 years ago

rtable-1 v0.2.4

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

GitHub license Build Status

This project is on pre-alpha stage. Stable version with documentation and finished styles will be available no later than January of 2020

React Table Control

The customizable, extendable, lightweight and free React Table Component

Can easily be included in react projects, never mind ts or js

// TODO Demo

Installation

npm

npm install react-table-control

yarn

yarn add react-table-control

Usage

A basic example

// TODO

API

Table

Properties

NameTypeDescription
columnsColumn[]Columns in table and their look and behaviour
dataany[]The data which is shown in Table's rows
editableCellsCell[]This property contains the array of cells which are being edited
editingModeEditingModeSets the table's editing mode
filterRowFilterCondition[]Sets filters for columns
groupsGroup[]Group's in the table
groupsExpandedTODOContains groups which are expanded in the grid
rowKeystringProperty of data's item which is used to identitify row
sortingModeSortingMode[]Sorting mode
search stringSpecifies the text which should be found in the data

Column

Describes column of table its look and behaviour Properties

NameTypeDescription
fieldstringSpecifies the property of data's object which value will be used in column
titlestringSpecifies the text of the header
dataTypeDataTypeSpecifies the type of column
sortDirectionSortDirectionSets the direction of sorting for the column
editorEditorFuncReturns an editor if cell is in editable mode
cellCellFuncReturns an custom cell if it is not in editable mode
widthnumber | stringSets the width of the column
textAlignTextAlignSets column's text alignment
searchSearchFuncOverrides the default search method for the cell. Executes if Table.search option is set
validationValidationFuncReturns the validation error string or does not return anything in case of passed validation

Cell

Describes the position of a cell in the table

Properties

NameTypeDescription
fieldstringThe field of
specific column
rowKeyValueanyData's key value of еру specific row

FilterCondition

Properties

NameTypeDescription
fieldstringThe filtered column's field
operatorstringOperator which will be applied for filtering
valueanyFiltered value

Group

Properties

NameTypeDescription
fieldstringThe grouped column's field

DataType

PropertyString value
Boolean'boolean'
Date'date'
Number'number'
Object'object'
String'string'

EditingMode

PropertyString valueDescription
None'none'Editing is disabled
Cell'cell'Data is edited by cell to cell, click by cell activates editing

SortDirection

PropertyString value
Ascend'ascend'
Descend'descend'

SortingMode

PropertyString value
None'none'
Single'single'

TextAlign

PropertyString value
Center'center'
Left'left'
Right'right'

EditorFunc

(props: ICellEditorProps) => any;

Function which obtains ICellEditorProps as parameter and returns React component which should be shown instead of default editor.

CellFunc

(props: ICellContentProps) => any;

Function which obtains ICellContentProps as parameter and returns React component which should be shown instead of cell content.

SearchFunc

(searchText?: string, rowData?: any, column?: Column) => boolean;

Function which obtains searchText?: string, rowData?: any, column?: Column - as parameters and returns boolean value which is true if cell's value is matched with searched value and false otherwise.

ValidationFunc

(value: any, rowData: any) => string | void;

Function which obtains value of specific cell and row - as parameters and returns validation error string or does not return anything in case of passed validation.

ICellEditorProps

Properties

NameTypeDescription
columnColumnsettings of the column in which editor is shown
rowDataanydata of the row in which editor is shown
close() => voidcall this method to close editor
onValueChange(newValue: any) => voidcall this method to change value of the row: onValueChange({ ...rowData, ...{ field: value } })

ICellEditorProps

Properties

NameTypeDescription
columnColumnsettings of the column in which editor is shown
openEditor() => voidcall this method to open editor of the cell
rowDataanydata of the row in which editor is shown
0.2.4

4 years ago