0.5.8 • Published 9 years ago

slavik-m-react-data-components v0.5.8

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

react-data-components

DataTable: Live demo and source.

Getting started

npm install slavik-m-react-data-components --save

Using the default implementation

The default implementation includes a filter for case insensitive global search, pagination and page size.

var React = require('react');
var DataTable = require('react-data-components').DataTable;

var columns = [
  { title: 'Name', prop: 'name', type: 'ELEMENT_STRING' },
  { title: 'City', prop: 'city', type: 'STRING' },
  { title: 'Address', prop: 'address', type: 'STRING' },
  { title: 'Phone', prop: 'phone', type: 'NUMBER' }
];

var data = [
  { id: 1, name: <a href="profile/1" sortValue="Victor"><span>Victor</span></a>, city: 'Kiev', address: 'some 
  address',  phone: '380634988888' },
  { id: 2, name: <a href="profile/2" sortValue="Ambassador"><span>Ambassador</span></a>, city: 'Kiev', address: 'some 
  address',  phone: '380634988888' },
  // It also supports arrays
  // [ 'name value', 'city value', 'address value', 'phone value' ]
];

React.render((
    <DataTable
      className="container"
      keys={[ 'id' ]}
      columns={columns}
      initialData={data}
      initialPageLength={5}
      initialSortBy={{ prop: 'name', order: 'ascending' }}
      pageLengthOptions={[ 5, 20, 50 ]}
    />
  ), document.body);

See complete example, see Flux example.

DataMixin options

keys: Array<string | number>

Properties that make each row unique, e.g. an id.

columns: Array<ColumnOption>

See Table column options.

pageLengthOptions: Array<number>

initialData: Array<object | Array<any>>

initialPageLength: number

initialSortBy: { prop: string | number, order: string }

Table column options

title: string

The title to display on the header.

prop: string | number

The name of the property or index on the data.

type: string[STRING|NUMBER|ELEMENT_STRING|ELEMENT_NUMBER]

ELEMENT_STRING or ELEMENT_NUMBER sort by React components. ReactElement need provide prop - "sortValue" to sort by this value; The title to display on the header.

render: (val: any, row: any) => any

Function to render a different component.

className: string | (val: any, row: any) => string

Class name for the td.

defaultContent: string

sortable: boolean

width: string | number

0.5.8

9 years ago

0.5.7

9 years ago

0.5.6

9 years ago

0.5.5

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.9

9 years ago

0.4.8

9 years ago

0.4.7

9 years ago

0.4.6

9 years ago

0.4.5

9 years ago

0.4.3

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.9

10 years ago

0.2.8

10 years ago

0.2.7

10 years ago

0.2.6

10 years ago

0.2.5

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago