0.1.6 • Published 4 years ago

rdatable v0.1.6

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

rdatable

React Data Table

Installation

Use the package manager npm to install datable.

npm install rdatable

HowTo

To render a datatable using rdatable you need 3 basic things

  1. Data | An array of any[]
  2. css classes for the search bar
  3. css classes for the pagginator

Implementing this is just simple (as the example below shows), just import the css style, import the component, thats all.

In the code bellow, you can see how a custom cell is rendered using typescript (TSX), if you're using javascript just access the property "Data"

Usage

import React from 'react'
import 'rdatable/build/css/style.css'
import Datable from 'rdatable/build'
import { IRenderProps } from 'rdatable/build/interfaces'

const Component = () => (
    <Datable 
        Color="dark" 
        CurrentPage={0} 
        Data={[
            {Id:0, Name: "Carlos"}, 
            {Id:1, Name: "Daniel"},
            {Id:2, Name: "Daniel"},
            {Id:3, Name: "Daniel"},
            {Id:4, Name: "Daniel"},
            {Id:5, Name: "Daniel"},
            {Id:6, Name: "Daniel"},
            {Id:7, Name: "Daniel"},
            {Id:8, Name: "Daniel"},
            {Id:9, Name: "Daniel"},
            {Id:10, Name: "Daniel"},
            {Id:11, Name: "Daniel"},
            {Id:12, Name: "Daniel"},
            {Id:13, Name: "Daniel"},
            {Id:14, Name: "Daniel"},
            {Id:15, Name: "Daniel"},
        ]} 
        Columns={[
            { Header: "Id", Filter: true, OrderBy: true, Item: "Id" }, 
            { Header: "Nombre", Filter: true, OrderBy: true, Item: "Name", 
                Render: (props: IRenderProps) => 
                {
                    console.log(props.Data.Name)
                    return (<span>{props.Data.Name}</span>)
                } 
            }
        ]} 
        Filter=""
        ItemsPerPage={10}
        OrderBy={[
        { Column: "Id", Order: 0 }
        ]}
        ShowFilter={true}
        FilterCustomize={{
            Container_Main_Class: "row justify-content-md-end",
            Container_Sub_Class: "col-sm-12 col-md-6",
            Input_Placeholder: "Buscar",
            Input_Container_Class: "input-group mb-2",
            Input_Control_Class: "form-control"
        }}
        PaginatorCustomize={{
            Container_Main_Class: "paginator-container mt-3",
            Button_List_Class: "btn-group",
            Button_Class: "btn btn-secondary", 
            Button_Active_Class: "btn btn-success"
        }}
    />
)



export default Component

Datable properties

proptypeDescriptionObligatoryDefault
Dataany[]Data to displayyes-
HeaderstringHeader on the tableyes-
FilterstringInitial filterno""
CurrentPagenumberCurrent page to initial renderno0
ItemsPerPagenumberNumber of items to render per pageno10
ShowFilterbooleanDisplay the filter componentnotrue
OrderByIOrderBy[]Default ordering of the tableno[]
FilterCustomizeIFilterCustomizeCSS Classes for the filternoNO CSS
PaginatorCustomizeIPaginatorCustomizeCSS Classes for the filternoNO CSS

Row properties

ProptypeDescriptionObligatoryDefault
Itemstring or string[]propert(y/ies) of the data to render, order and fiter if enabledyes-
FilterbooleanEnable filtering data based on this columnnofalse
OrderBybooleanEnable ordering data based on this columnnofalse
RenderfunctionRenders this cell using a custom render, the render implements IRenderProps [Data: any, Table: IDatable Datable properties]nodefault render on span

IFilterCustomize

ProptypeDescriptionObligatoryDefault
Container_Main_ClassstringCss class name for the main divno-
Button_List_ClassstringCss class name for the div containing the controlsno-

IPagginatorCustomize

ProptypeDescriptionObligatoryDefault
Container_Main_ClassstringCss class name for the main divno-
Button_List_ClassstringCss class name for button list divno-
Button_ClassstringCss class name for each button buttonno-
Button_Active_ClassstringCss class name for the active page buttonno-

Git repository

Github

License

MIT

0.1.6

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago