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

react-mui-data-table

v1.1.8

Published

Eash to use DataTable library using ReactJS & MaterialUI

Downloads

29

Readme

react-mui-data-table

Eash to use DataTable library using ReactJS & MaterialUI Support row editing (Textbox & Combobox)

NPM JavaScript Style Guide

mui-data-table mui-data-table mui-data-table

Install

npm install --save react-mui-data-table

Usage

import React from 'react';
import { MUITable } from 'mui-data-table';

const customStyle = {
  width: '98%',
  '& .rmdt-table': {
    width: '100%',
    height: '100%',
    boxShadow: 'none',
    '& .MuiTable-root': {}
  }
};

const COLUMNS = [
  {
    _id: '_id',
    label: 'ID',
    display: false
  },
  {
    _id: 'col1',
    label: 'COL1',
    width: 100,
    format: function (val) {
      return (
        <div
          className='rmdt-cell-inner'
          style={{ fontWeight: 'bold', color: '#2478FF' }}
        >
          {val}
        </div>
      );
    }
  },
  {
    _id: 'col2',
    label: 'COL2',
    width: 100,
    editable: true,
    editType: 'combobox',
    items: [
      { key: 'y', value: 'Y' },
      { key: 'y', value: 'N' }
    ]
  },
  {
    _id: 'col3',
    label: 'COL3',
    width: 100,
    editable: true
  },
  {
    _id: 'col4',
    label: 'COL4',
    width: 150,
    subHeader: [
      {
        _id: 'col4_1',
        label: 'COL4_1',
        format: (val) => `${numberFormat(val)}$`
      },
      {
        _id: 'col4_2',
        label: 'COL4_2'
      },
      {
        _id: 'col4_3',
        label: 'COL4_3'
      }
    ]
  },
  {
    _id: 'col5',
    label: 'COL5',
    width: 100,
    format: (val) => numberFormat(val)
  }
];

const numberFormat = (val) => {
  if (this === 0) return 0;
  const reg = /(^[+-]?\d+)(\d{3})/;
  val = val.toString();
  while (reg.test(val)) val = val.replace(reg, `$1,$2`);
  return val;
};

const DataTable = () => {
  const getItems = () => {
    const items = [];
    for (let i = 0; i < 25; i++) {
      let o = {
        _id: `ID ${i}`,
        col1: `COL1 ${i}`,
        col2: `COL2 ${i}`,
        col3: `COL3 ${i}`,
        col4: `COL4 ${i}`,
        col4_1: parseInt(Math.random() * 10000),
        col4_2: `COL4_2 ${i}`,
        col4_3: `COL4_3 ${i}`,
        col5: parseInt(Math.random() * 10000000)
      };
      items.push(o);
    }
    return items;
  };

  return (
    <div
      className='react-mui-data-table-container'
      style={{ width: '1200px', height: '1000px', padding: '20px' }}
    >
      <MUITable
        className='custom-style-rmdt' // You can import css file and force it to be applied to the css
        customStyle={customStyle} // This will be added under the rmdt class
        items={getItems()}
        columns={COLUMNS}
        checkBox={true} // {true || false}
        count={true} // {true || false}
        pagination={true} // {true || false}
        border={true} // {true || false}
        labelRowsPerPage={({ rowsPerPage }) =>
          `Rows in one page (${rowsPerPage})`
        }
        labelItemCount={(items, rowsPerPage, page) =>
          `Total: ${items.length}, ${rowsPerPage * page + 1} ~ ${
            rowsPerPage * page + rowsPerPage
          }`
        }
        labelDisplayedRows={({ page, rowsPerPage }) =>
          `${page}, ${rowsPerPage}`
        }
        onCheck={(selected) => console.log(selected)}
        onCheckAll={(selected) => console.log(selected)}
        handleData={(row) => console.log(row)}
      />
    </div>
  );
};

export default DataTable;

Version History

Version 1.1.8 New Features

  • Checkbox Single Selection

Version 1.1.7 Bug Fix

  • When using format with ComboBox

Version 1.1.5 New Features

  • React components format in columns.js

Version 1.1.4 New Features

  • customStyle={} // Will be added under 'rmdt class'. Write css in material ui style format.

Version 1.1.2 New Features

  • border={true || false}

Version 1.1.0 New Features

  • labelRowsPerPage
  • labelItemCount
  • labelDisplayedRows

License

MIT ©