1.3.4 • Published 2 years ago
@eduenano27/react-datatable v1.3.4
React DataTable
Install
npm install @eduenano27/react-datatable
DataTable\ Attributes
Attribute | Type | Description | Default |
---|---|---|---|
autoRefresh | number | Seconds to refresh table data | disabled |
showLimit | boolean | Show row limit | false |
showSearch | boolean | Show search box | false |
showPagination | boolean | Show pagination | true |
src | string | API Endpoint | null |
className | string | Table container class name | null |
columns | ITableColumn\[] | Table columns | null |
ITableColumn\ Attributes
Attribute | Type | Description |
---|---|---|
caption | any | Column header |
captionClass | string | Column header class |
row | (props: ITableRow\) => any | Row value |
cellClass | (props: ITableRow\) => string | Row class |
ITableRow\ Attributes
Attribute | Type | Description |
---|---|---|
row | \ | Row value |
flush | () => void | Force refresh API data |
FAQ
· Crash when invoke `flush`: You have to replace this on table column `row: ColumnComponent,` by `row: row => <ColumnComponent { ...row }/>,`
Example
import React from "react";
import DataTable from "@eduenano27/react-datatable";
interface IFakeUser {
id: number,
name: string,
email: string
}
export default function TableComponent() {
return (
<DataTable<IFakeUser>
showLimit
showSearch
src='/api/players'
header={ ({ limit, search, flush }) => <div>Header</div> }
columns={ [
{
caption: 'ID',
captionClass: 'text-center',
row: ({ row }) => row.id,
cellClass: ({ row }) => 'text-center'
},
{
caption: 'Nombre',
captionClass: 'text-center',
row: ({ row }) => row.name,
cellClass: ({ row }) => 'text-center'
},
{
caption: 'Opciones',
row: ({ row, flush }) => {
return (
<div>
<a href={ `mailto:${ row.email }` }>{ row.email }</a>
<button onClick={ flush }>test reload ({ row.id })</button>
</div>
);
}
}
] }/>
);
}
1.3.4
2 years ago
1.3.3
2 years ago
1.3.2
2 years ago
1.3.1
2 years ago
1.3.0
2 years ago
1.2.8
2 years ago
1.2.7
2 years ago
1.2.6
2 years ago
1.2.9
2 years ago
1.2.5
3 years ago
1.2.4
3 years ago
1.2.3
3 years ago
1.2.2
3 years ago
1.2.1
3 years ago
1.2.0
3 years ago
1.1.9
3 years ago
1.1.8
3 years ago
1.1.7
3 years ago
1.1.6
3 years ago
1.1.5
3 years ago
1.1.4
3 years ago
1.1.2
3 years ago
1.1.1
3 years ago
1.1.0
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago