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

mui-react-datatables

v0.0.14

Published

Material-UI Datatables

Downloads

39

Readme

Material-UI React Datatablrs

| | build status | build version | downloads | | ------------ | ------------ | ------------ | ------------ | | latest | Build Status | npm package | NPM Downloads | | dev | Build Status | npm package | NPM Downloads |

MUI Datatables is a library that takes an array of json data and displays it in a simple, configurable way. This library was inspired by mui-datatables however I plan to address many of the shortcomings of this library in my own implementation such as: a footer row to be used for totals, multi-sorting of columns, key-driven configuration (vs index-based), and more to come.

Getting Started

Installation

npm install mui-react-datatables

or

yarn add mui-react-datatables

Using the table

import MUIDatatable from 'mui-react-datatables'

Table Options

const options = {
	fillEmptyRows: true,
	rowsPerPage: 10,
}

Column Options

const columns = [
    {
        title: "Name",
        Cell: item => `${item.name.first} ${item.name.last}`
    },
    {
        title: "Company",
        accessor: "company",
    },
    {
        title: "Age",
        accessor: "age",
    },
    {
        title: "Phone",
        accessor: "phone",
        sortValue: item => parseInt(item.phone.replace(/[^0-9]+/g,"")),
    },
    {
        title: "Balance",
        accessor: "balance",
        sortValue: item => parseFloat(item.balance.replace(/[^0-9.-]+/g,"")),
    },
    {
        title: "Picture",
        Cell: (item) => <img src={item.picture} style={{width: 32, height: 32}} />,
        visible: false,
    },
]

Optional Refs

const [filters, setFilters] = useState([])
const [sorts, setSorts] = useState([])

Implementation

<MUIDatatable
	title={"My Table"}
	data={data}
	columns={columns}
	options={options}
	filtersRef={setFilters}
	sortsRef={setSorts}
/>

API

<MUIDatatable />

The component accepts the following props:

|Name|Type|Default|Required|Description |:--:|:-----|:-----|:-----|:-----| |title|string|""|false|Title of the table |options|object|{}|true|Options to be supplied to table. |columns|[object]|[]|true|Columns to be displayed in the table. |data|[object]|[]|true|Data to be supplied to table. |filtersRef|function||false|Accessor for filters array. (filters) => {} |sortsRef|function||false|Accessor for sorts array. (sorts) => {} |filteredDataRef|function||false|Accessor for filtered data. (filteredData) => {}

options:

|Name|Type|Default|Required|Description |:--:|:-----|:--|:-----|:-----| |fillEmptyRows|bool|false|false|Should the table fill empty rows with blanks. |rowsPerPage|number|10|false|Number of rows displayed on a page. |csvExport|boolean|true|false|Display CSV export button. |csvFilename|string|title || "table"|false|Filename for CSV export. |initialSorts|[object]|[]|false|Initial sorting list. |initialFilters|[object]|[]|false|Initial filtering list. |onRowClick|function||false|Function call when row is clicked. (row, event) => {} |maxRowHeight|number|null|false|Max height of a row. |footerRow|[object]|[]|false|Should the footer row be displayed. |highlightedRowId|number|null|false|id of row to highlight. |loading|boolean|false|false|Should table display loading cell. |LoadingCell|function||false|Component to render when loading is true |NoRowsCell|function||false|Component to render when data.length is 0

columns[]:

|Name|Type|Default|Required|Description |:--:|:-----|:--|:-----|:-----| |id|string|index|false|Unique identifier. Used for reference in initialSorts and initialFilters |title|string||true|Title of the column |accessor|string||true*|Key of value in row to display.*not required if using Cell |Cell|function||false|Render function of the cell. Overrides accessor (value, row) => {} |LoadingCell|component||false|Loading component of the cell. Overrides accessor |Footer|function||false|Render function of the cell footer. (data, column) => {} |sortable|bool|true|false|Can this column be sorted using column headers. |sortValue|function||false|Custom sort value. Defaults to accessor then Cell. (value, row) => {} |filterable|bool|true|false|Can this column be filtered / searched on. Applies to both column filters and global search. |filterValue|function||false|Custom filter value. Defaults to accessor then Cell. (value, row) => {} |filterType|string|select|false|select: dropdown based on available valuestext: free textfield inputnumeric: comparison operations + numeric input |hideable|bool|true|false|Can the column be hidden / unhidden |visible|bool|true|false|Is the column visible by default. User can unhide if hideable is set to true |csvHeader|string|title|false|Header for the column. |csvValue|string||false|Value to be exported for cell. Default is what renders to the table. (value, row) => {}