1.3.4 • Published 2 years ago

@eduenano27/react-datatable v1.3.4

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
2 years ago

React DataTable

Install

npm install @eduenano27/react-datatable

DataTable\ Attributes

AttributeTypeDescriptionDefault
autoRefreshnumberSeconds to refresh table datadisabled
showLimitbooleanShow row limitfalse
showSearchbooleanShow search boxfalse
showPaginationbooleanShow paginationtrue
srcstringAPI Endpointnull
classNamestringTable container class namenull
columnsITableColumn\[]Table columnsnull

ITableColumn\ Attributes

AttributeTypeDescription
captionanyColumn header
captionClassstringColumn header class
row(props: ITableRow\) => anyRow value
cellClass(props: ITableRow\) => stringRow class

ITableRow\ Attributes

AttributeTypeDescription
row\Row value
flush() => voidForce 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