All Projects → filipdanic → Spicy Datatable

filipdanic / Spicy Datatable

Licence: mit
React.js datatables without jQuery. Smart react datatable that includes search, pagination and localization.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Spicy Datatable

Material Ui Datatables
An another React Data tables component.
Stars: ✭ 163 (+352.78%)
Mutual labels:  react-component, datatables
React Splide
The Splide component for React.
Stars: ✭ 32 (-11.11%)
Mutual labels:  react-component
React Visual Diff
React component for rendering the diff of two React elements
Stars: ✭ 22 (-38.89%)
Mutual labels:  react-component
React Notie
Simple notifications for react
Stars: ✭ 27 (-25%)
Mutual labels:  react-component
React Input Number
React number input component
Stars: ✭ 7 (-80.56%)
Mutual labels:  react-component
React Prismazoom
A pan and zoom component for React, using CSS transformations.
Stars: ✭ 29 (-19.44%)
Mutual labels:  react-component
Base
React-UI-Kit - frontend library with ReactJS components
Stars: ✭ 18 (-50%)
Mutual labels:  react-component
Vue Data Tables
A simple, customizable and pageable table with SSR support, based on vue2 and element-ui
Stars: ✭ 976 (+2611.11%)
Mutual labels:  datatables
React Colorful
🎨 A tiny (2,5 KB) color picker component for React and Preact apps
Stars: ✭ 951 (+2541.67%)
Mutual labels:  react-component
React Absolute Grid
An absolutely positioned, animated, filterable, sortable, drag and droppable, ES6 grid for React.
Stars: ✭ 910 (+2427.78%)
Mutual labels:  react-component
React Hanko
A Japanese hanko component for React.js
Stars: ✭ 14 (-61.11%)
Mutual labels:  react-component
Ui Box
Blazing Fast React UI Primitive
Stars: ✭ 847 (+2252.78%)
Mutual labels:  react-component
React Grid Carousel
React responsive carousel component w/ grid layout
Stars: ✭ 29 (-19.44%)
Mutual labels:  react-component
Lightning Data Grid
A data grid for Lightning Component Framework
Stars: ✭ 24 (-33.33%)
Mutual labels:  datatables
React Animated Weather
Animated weather component for React inspired by Skycons http://darkskyapp.github.io/skycons/ ☀️
Stars: ✭ 34 (-5.56%)
Mutual labels:  react-component
Sparkline
Lightweight React sparklines ✨ 📈
Stars: ✭ 19 (-47.22%)
Mutual labels:  react-component
React Facial Feature Tracker
React Component for Facial Feature Recognition based on the clmtracker
Stars: ✭ 13 (-63.89%)
Mutual labels:  react-component
Dt54
Laravel 5.4 DataTables Demo Application (WIP)
Stars: ✭ 27 (-25%)
Mutual labels:  datatables
React Notifications Component
Delightful and highly customisable React Component to notify your users
Stars: ✭ 978 (+2616.67%)
Mutual labels:  react-component
React Markdown Preview
React component preview markdown text in web browser. The minimal amount of CSS to replicate the GitHub Markdown style.
Stars: ✭ 34 (-5.56%)
Mutual labels:  react-component

spicy-datatable

A React.js datatables without jQuery. Smart datatable component that includes search, pagination, CSV export, and localization support.

Demos:

Jump to:

Install

To get started with spicy-datatable in your project:

npm i spicy-datatable --save
# or
yarn add spicy-datatable

Then, in your code:

import SpicyDatatable from 'spicy-datatable';
// …somewhere:
<SpicyDatatable
  tableKey={key} // see below for prop documentation
  columns={columns}
  rows={rows}
  config={config} // optional, used to override chosen default settings/labels
/>

Now you are all set to enjoy some ReactJS datatables in your project! No jQuery or other heavy dependencies. 🙌

Look at the demo data file for examples of how the rows and columns props look.

You can also clone this repo which includes a full demo with create-react-app that you can use to try out the library.

Required Prop Docs

The tableKey is a String used to identify the table dataset. It is required.

The columns prop is an array of colum objects which have a key and label. Like this:

const columns = [{
    key: 'userId',
    label: '#',
  }, {
    key: 'name',
    label: 'Name',
    sort: true, // will enable a client-side sort for this column!
  }, {
    key: 'email',
    label: 'Email',
  },
];

The rows prop is an array of objects that have the key: value pairs described in our columns. For example:

const rows = [
  {
    userId: 1,
    name:  'Sansa Stark',
    email: '[email protected]',
    onClickHandler: someFunction,
    isActive: true,
  },
  {
    userId: 2,
    name: 'Jon Snow',
    email: '[email protected]',
    onClickHandler: someFunction,
    isActive: false,
  },
];
  • The onClickHandler is optional. It will attach an onClick() callback on the row. Your handler will receive three params:
    • event {Object}, the proxied React click event
    • row {Object}, the row that was clicked
    • index {Number}, the index of the item within the currently visible table view
  • The isActive prop is also optional. The row that has this prop set to true will have a special class applied (CSS styling purposes.)

Config prop

You can pass a config prop the <SpicyDatatable /> component to change all the default settings and labels.

This is great if you want to change the text or localize your component. Here’s an overview of all the options you can specify via the config object.

See the customOptions object in the demo data for an example of how it is used in example #2 on the demo page.

Pagination Config

  • itemsPerPageOptions: an Array of Numbers, defaults to [10, 25, 50, 100],
  • itemsPerPageLabel: a String, defaults to Entries per page:
  • nextPageLabel: a String, defaults to Next
  • previousPageLabel: a String, defaults to Back

Search Config

  • searchLabel: a String, defaults to Search:
  • searchPlaceholder: a String, defaults to Type to search…

CSV Export Config

  • showDownloadCSVButton: a Boolean to turn the CSV export on or off, defaults to false.
  • downloadCSVButtonLabel: a String to change the label on the CSV button, defaults to Export CSV.
  • customCSVKeys: an Array of Strings to specify which keys should be included in the exported CSV.
  • customCSVRowsFormatter: a Function that receives a single parameter rows of type Array and returns a similar structure back. Use this prop to format data that will be in the CSV.

Misc Labels

  • noEntriesLabel: a String, defaults to No entries to show.
  • entryCountLabels: an Array of Strings, defaults to ['Showing', 'to', 'of', 'entries.']. Prints out Showing 10 to 20 of 300 entires. at the bottom of the table.

Custom Filter

  • customFilter: a Function() that can be used to override the default search logic. It will get three params: (rows, columns, searchQuery) and should return a new rows of type Array.

Example:

Say you want to only search for matches in the name column while ignoring case sensitivity:

const customFilter = (rows, columns, searchQuery = '') => {
  return rows.filter(row => row.name.toLowerCase().indexOf(searchQuery.toLowerCase()) > -1);
}

Styling

Out of the box, spicy-datatable is bare-bones. Include this CSS starter file in your project to get the look from the demo. Edit it to suit your needs.

FAQ

Q: I want the search feature to account for accidental typos (or implement a different type of logic altogether). A: Check the prop config object, it has a customFilter options. Here’s a sample object that has a custom filter function.

Q: Is this component compatible with React 15.5.x? A: Yep! And we’ll be switching to 16.x.x once it’s stable.

Q: Is the CSV export supported by MS Edge / Internet Explorer 11? A: Yep, and it should be supported by IE9+.

Q: There is no CSV button in my table?! A: This CSV export is an optional feature, you need to turn it on via a prop config object.

Q: How can I style the CSV button? A: The button has a CSS class spicy-datatableoptions-export--button and is wrapped by spicy-datatableoptions-export--button-wrapper. See the sample from the styling section.

Roadmap

  • (Optional) Bootstrap styles!
  • Unit and performance tests.
  • Sortable columns.
  • PDF/Excel download

Contribute

There are many ways to contribute. For example:

  • Test the library in your project, open an issue if you find bugs or problems!
  • If you are enjoying the library, star it here on Github to show your support.
  • Have a feature request? Want the roadmap to hurry up? Open a feature request via the issues tab.
  • Fixed a problem or added a feature on your fork? Send a PR to make it part of the main distribution.
  • The docs could be better? Found a typo? Submit a PR!

Contributors

Need help with your first PR in OSS? Open an issue and we will find something simple and cool for you!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].