0.0.6 • Published 2 years ago

paginating-sorting v0.0.6

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

Dynamic table with paging and sorting

for interface paginatingAndSorting of Spring Boot or other aplication with same params. see dataTable example

Parameters

  • dataTable = {dataTableProperties}
  • onChange = (resp: {order: string, page: number,sort: string}) => void

dataTable properties

NameTypeRequiredDescription
contentArray<{[key: string]: any}>NotJSONs array to populate the table.
maxItemsShownumberNotMaximum amount of items (pages) to show in the pagination. Default 3.
numbernumberYesNumber of the current page
showLastedAndFirstbooleanNotAllows to show or not the buttons to go back "«" and forward "»" the next X amount of pages. Default true
showPaginationbooleanNotAllows to show or not show pagination. Default true
titlesArray<TitleTableProps>YesTitles for table columns.
totalPagesnumberYesTotal pages.

dataTable example

{
    "content":[
        {"id": 1,
        "name": "name1",
        "address": {
            "city": "ciudad1",
            "State": "State1",
            "Country": "Country1"
        }}...
    ],
    "number":0,
    "totalPages":10,
    "titles":[
        ...
    ]
}

Titles properties (TitleTableProps)

NameTypeRequiredDescription
sortstringNotBase text string to return when sorting a column, if not sent, the options in that column are hidden.
namestring or Array<string>Yes, if you don't send sortKey to locate the value to show in the column. If it's a nested value, the keys are separated by a period. If you want to concatenate values in a column, the keys are sent in an array.
titleanyYesTitle to show Columns in the table.

Titles example

{"titles":[
    {
        "title":"ID",
        "sort":"id"
    },
    {
        "title":"Address",
        "sort":"city",
        "name":["address.city","address.state"]
    }
]}

How to use

import { Table } from 'paginating-sorting'
const handleChangeTable = (pageAction) =>{
	console.log(pageAction);//order: string, page: number, sort: string
}
<Table dataTable={dataTable} onChange={handleChangeTable}/>