Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-material-infinite-datatable

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-material-infinite-datatable

An inifite table for React that implements Material-UI as it base styles

  • 0.1.0-beta.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

react-material-infinite-datatable

NPM JavaScript Style Guide

Install

npm install --save react-material-infinite-datatable

Usage

import React, { Component } from 'react';
import { VirtualizedTable } from 'react-infinite-datatable';
import faker from 'faker';

class MyPage extends Component {
	private readonly PAGE_SIZE = 50;

	generateData(pageNumber: number): Array<any> {
		const rows = [];
		for (let i = 0; i < this.PAGE_SIZE; i++) {
			rows.push({
				idx: i + (this.PAGE_SIZE * (pageNumber - 1)) + 1,
				firstname: faker.name.findName(),
				email: faker.internet.email(),
				address: {
					address1: faker.address.streetAddress()
				},
				arr: [{
					field1: 'val1'
				}]
			});
		}
		return rows;
	}

	loadMoreRows = (pageNumber: number): Promise<Array<any>> => {
		return new Promise(resolve => {
			setTimeout(() => {
				const rows = this.generateData(pageNumber);
				resolve(rows);
			}, 3000);
		});
	}
  
	render() {
		const moreRows = this.loadMoreRows.bind(this);

		return (
			<VirtualizedTable
				pageSize={this.PAGE_SIZE}
				loadData={moreRows}
				selectable
				columns={[
					{
						label: '#',
						dataKey: 'idx',
						type: 'number',
						format: '0,0'
					},
					{
						label: 'Name',
						dataKey: 'firstname'
					},
					{
						label: 'Email',
						dataKey: 'email',
						headerRenderer: (column: InfiniteColumn) => {
							return (<div>{column.label + '...'}</div>);
						},
						renderer: (_column: InfiniteColumn, row: any) => {
							return (<div>{row.email}: {row.idx}</div>)
						}
					},
					{
						label: 'Street',
						dataKey: 'address.address1'
					},
					{
						label: 'Array Value',
						dataKey: 'arr[0].field1'
					}
				]}
			/>)
	}
}

License

MIT ©

FAQs

Package last updated on 22 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc