npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

data-table-reactjs

v0.2.33

Published

React Table with sort filter pagination and download

Downloads

14

Readme

data table reactjs Key Features

  • Declarative Configuration
  • Built-in and configurable:
    • Sorting
    • Filtering
    • Download
    • Pagination
  • Themeable/Customizable
  • Responsive

Installation

Data table react has only react as dependancy no other third party library is used.

API and Usage

Columns

Nothing new here - we are using an array of object literals and properties to describe the columns:

| Property | Type | Required | Example | | ---------- | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | name | string | yes | the display name of our Column e.g. 'Name' | | selector | string | yes | a data set unique property in dot notation. e.g. property1.nested1 . A selector is required anytime you want to display data but can be ommitted if your column does not require showing data (e.g. an actions column) | | sortable | bool | no | if the column is sortable. columns will be sorted using basic sor functions and will have ability to sort string, date, number | | filterable | bool | no | if the column is filterable. Rows will be filter by converting data to string type |

Actions

| Property | Type | Required | Default | Description | | --------- | -------- | -------- | ------- | ------------------------------------------------------------------------------ | | key | string | yes | | key to should be unique | | label | string | no | | label for the action | | handler | function | yes | | Call back to be called after action click which should accept index , item | | className | string | no | | class for the action |

ReactDataTable Properties

Basic

| Property | Type | Required | Default | Description | | --------------------- | ------------------- | -------- | ------- | -------------------------------------------------------------------- | | title | string | no | | The Title displayed in the Table Header | | columns | array | yes | [] | The column configuration | | isLoading | bool | no | | Show a loader | | loadingComponent | Component or string | no | | custom component to display | | list | array | yes | [] | List of records containing properties with name of column selector | | actions | array | no | [] | The action configuration | | pagination | bool | no | false | to enable pagination | | showSerialNumber | bool | no | false | to show the serial number as first column of table | | showDownloadOption | bool | no | false | to show download file option | | defaultValForEmpty | string | no | '-' | Val to display when there is no value for any column | | initiallyVisibleCol | array | no | all | Columns to be diplayed intitally | | hideOptionToSelectCol | bool | no | false | Hide option to select columns |

Class Names to modify styles of table

the class names are self explantory and can be used to customize the table view containerClass | titleContainerClass | titleClass | downloadDropDownContainerClass | downloadDropDownClass | tableClass | tableWapperClass | headerRowClass | headerCellClass | headerIconContainerClass | filterInputContainerClass | filterInputFieldClass | filterInputApplyClass | tableBodyClassName | tableRowClass | tableCellClass | actionsClass | tableFooterClass | pageSizeDropDownContainerClass | pageSizeDropDownClass | pageNumberContainerClass | pageNumberCellClass | activePageCellClass | react-data-table-multi-select-dropdown | react-data-table-action-cell | react-data-table-action-cell-item All classes can be passed to table

Usage example

import ReactDataTable from 'data-table-reactjs';
const columns = [
  {
    name: 'column 1',
    selector: 'column1',
  },
  {
    name: 'column 2',
    selector: 'column2',
  },
];
const actions = [
  {
    key: 'viewDetails',
    handler: (index, item) => {
      console.log(index, item);
    },
    label: 'View record',
  },
];
const list = [
  {
    column1: 'Value 1',
    column2: 'value 2',
  },
  {
    column1: 'Value 3',
    column2: 'value 4',
  },
  {
    column1: 'Value 5',
    column2: 'value 6',
  },
];
const MyComponent = () => (
  <ReactDataTable
    title="Title of the table"
    columns={columns}
    list={list}
    actions={actions}
    showSerialNumber
  />
);