

GitHub - mbrn/material-table: Datatable for React based on material-ui's...
source link: https://github.com/mbrn/material-table
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
material-table
A simple and powerful Datatable for React based on Material-UI Table with some additional features.
Key features
- Actions
- Component overriding
- Custom column rendering
- Detail Panel
- Editable
- Export
- Filtering
- Grouping
- Localization
- Remote Data
- Search
- Selection
- Sorting
- Styling
- Tree Data
- and more
Demo and documentation
You can access all code examples and documentation on our site material-table.com.
Support material-table
To support material-table visit SUPPORT page.
Prerequisites
The minimum React
version material-table supports is ^16.8.5
since material-table v1.36.1
. This is due to utilising react-beautiful-dnd
for drag & drop functionality which uses hooks.
If you use an older version of react we suggest to upgrade your dependencies or use material-table 1.36.0
.
Installation
1.Install package
To install material-table with npm
:
npm install material-table --save
To install material-table with yarn
:
yarn add material-table
2.Add material icons
There are two ways to use icons in material-table either import the material icons font via html OR import material icons and use the material-table icons
prop.
HTML
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
OR
Import Material icons
Icons can be imported to be used in material-table offering more flexibility for customising the look and feel of material table over using a font library.
To install @material-ui/icons with npm
:
npm install @material-ui/icons --save
To install @material-ui/icons with yarn
:
yarn add @material-ui/icons
If your environment doesn't support tree-shaking, the recommended way to import the icons is the following:
import AddBox from "@material-ui/icons/AddBox"; import ArrowUpward from "@material-ui/icons/ArrowUpward";
If your environment support tree-shaking you can also import the icons this way:
import { AddBox, ArrowUpward } from "@material-ui/icons";
Note: Importing named exports in this way will result in the code for every icon being included in your project, so is not recommended unless you configure tree-shaking. It may also impact Hot Module Reload performance. Source: @material-ui/icons
Example
import { forwardRef } from 'react'; import AddBox from '@material-ui/icons/AddBox'; import ArrowUpward from '@material-ui/icons/ArrowUpward'; import Check from '@material-ui/icons/Check'; import ChevronLeft from '@material-ui/icons/ChevronLeft'; import ChevronRight from '@material-ui/icons/ChevronRight'; import Clear from '@material-ui/icons/Clear'; import DeleteOutline from '@material-ui/icons/DeleteOutline'; import Edit from '@material-ui/icons/Edit'; import FilterList from '@material-ui/icons/FilterList'; import FirstPage from '@material-ui/icons/FirstPage'; import LastPage from '@material-ui/icons/LastPage'; import Remove from '@material-ui/icons/Remove'; import SaveAlt from '@material-ui/icons/SaveAlt'; import Search from '@material-ui/icons/Search'; import ViewColumn from '@material-ui/icons/ViewColumn'; const tableIcons = { Add: forwardRef((props, ref) => <AddBox {...props} ref={ref} />), Check: forwardRef((props, ref) => <Check {...props} ref={ref} />), Clear: forwardRef((props, ref) => <Clear {...props} ref={ref} />), Delete: forwardRef((props, ref) => <DeleteOutline {...props} ref={ref} />), DetailPanel: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />), Edit: forwardRef((props, ref) => <Edit {...props} ref={ref} />), Export: forwardRef((props, ref) => <SaveAlt {...props} ref={ref} />), Filter: forwardRef((props, ref) => <FilterList {...props} ref={ref} />), FirstPage: forwardRef((props, ref) => <FirstPage {...props} ref={ref} />), LastPage: forwardRef((props, ref) => <LastPage {...props} ref={ref} />), NextPage: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />), PreviousPage: forwardRef((props, ref) => <ChevronLeft {...props} ref={ref} />), ResetSearch: forwardRef((props, ref) => <Clear {...props} ref={ref} />), Search: forwardRef((props, ref) => <Search {...props} ref={ref} />), SortArrow: forwardRef((props, ref) => <ArrowUpward {...props} ref={ref} />), ThirdStateCheck: forwardRef((props, ref) => <Remove {...props} ref={ref} />), ViewColumn: forwardRef((props, ref) => <ViewColumn {...props} ref={ref} />) }; <MaterialTable icons={tableIcons} ... />
Usage
Here is a basic example of using material-table within a react application.
import React, { Component } from "react"; import ReactDOM from "react-dom"; import MaterialTable from "material-table"; class App extends Component { render() { return ( <div style={{ maxWidth: "100%" }}> <MaterialTable columns={[ { title: "Adı", field: "name" }, { title: "Soyadı", field: "surname" }, { title: "Doğum Yılı", field: "birthYear", type: "numeric" }, { title: "Doğum Yeri", field: "birthCity", lookup: { 34: "İstanbul", 63: "Şanlıurfa" } } ]} data={[ { name: "Mehmet", surname: "Baran", birthYear: 1987, birthCity: 63 } ]} title="Demo Title" /> </div> ); } } ReactDOM.render(<App />, document.getElementById("react-div"));
Contributing
We'd love to have your helping hand on material-table
! See CONTRIBUTING.md for more information on what we're looking for and how to get started.
If you have any sort of doubt, idea or just want to talk about the project, feel free to join our chat on Gitter :)
License
This project is licensed under the terms of the MIT license.
Recommend
-
61
VueDatatable - Bulma themed, VueJS powered Datatable with server-side loading and JSON template setup
-
38
平时写代码的时候经常会遇到DataTable与List<T>之间的转换操作,由于DataTable数据集合不像List<T>指定了对应的T类型,所以在操作的时候没有List<T>方便,为了方便两个集合的转换,特此写下以下类记录两者之间的互换。classModelConvertHelper&l...
-
29
“There were 5 Exabytes of information created between the dawn of civilization through 2003, but that much information is now created every 2 days”:Eric Schmidt If you a...
-
47
虽然pandas是数据分析、机器学习等必备利器,但现在流行的机器学习应用训练模型动辄需要GB级别的数据,很多时候pandas无法快速读取大数据文件或者进行高效运算,甚至可能存在内存溢出等情况。 如果是R语言的用户应该很熟悉data.t...
-
48
jQuery Datatables For Laravel 5.x A simple package to ease datatable.js server side operations This package is created to handle server-side...
-
13
java-version.com: What's new in Java 16? 15? Keep up to date! JSF: commandLink and datatable a small nightmare Ma...
-
31
Angular Datatable to Export data into Excel, CSV, PDF, Print and Copy I have already shared angular datatable...
-
6
Presenting Data with the Webix DataTableJune 19th 2021 new story5
-
12
【答客問】NSwag WebAPI 回傳 DataTable 發生 JSON property 'Item' is defined multiple times 錯誤-黑暗執行緒讀者 Bike 提到「NSwag 遇...
-
36
Convert DataTable to Spreadsheet with the New DataTableFormatProvider This post explains how to use the new DataTableFormatProvider to convert a...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK