tubular-react

Material UI table with local or remote data-source. Featuring filtering, sorting, free-text search, export to CSV locally, and aggregations.

Github星跟踪图

Analytics
npm version
Buils status

Tubular-React

:star: Please star this project if you find it useful!

Tubular-React is a Material-UI table (or data grid) with local or remote data-source. Featuring:

  • Define a custom layout for columns and cells using render methods.
  • Use a remote or local datasource. Remote datasource use a specific Request and Response format.
  • Sort and filter multiple columns.
  • Free-text search of string columns.
  • Page data. Remote data is paged in the server side.
  • Export data to a CSV file.
  • Print data.

You can try a CodeSandbox demo.

Please visit the Tubular GitHub Page to learn how quickly you can start coding. See Related projects below to discover more Tubular libraries and backend solutions.

Table of contents

Installation

$ npm install tubular-react --save

Usages

You can check the documentation of the components at https://unosquare.github.io/tubular/tubular-react

DataGrid

You can start using DataGrid with this sample code. The grid will connect to a remote datasource or have a local datasource depending on what it's passed in the dataSource property.

import React from 'react';
import ReactDOM from 'react-dom';

import { DataGrid } from 'tubular-react';
import { ColumnModel } from 'tubular-common';

const columns = [new ColumnModel('OrderID'), new ColumnModel('CustomerName'), new ColumnModel('ShipperCity')];

const SampleGrid = () => (
    <DataGrid columns={columns} dataSource={'https://tubular.azurewebsites.net/api/orders/paged'} gridName="Grid" />
);

ReactDOM.render(<SampleGrid />, document.getElementById('root'));

This is a preview of the previous code:

DataGrid

Using a remote data source

You will need both a URL and a ColumnModel array.

<DataGrid columns={columns} dataSource={'https://tubular.azurewebsites.net/api/orders/paged'} gridName="Grid" />

Example

You can try a CodeSandbox demo for RemoteDataGrids:

Edit tubular-react - dataGrid

Using a local data source

You will need both an array of data objects and a ColumnModel array. See this example of how to define the array of objects.

<DataGrid columns={columns} dataSource={localData} gridName="Grid" />

Example

You can try a CodeSandbox demo for LocalDataGrid

Edit tubular-react - localDataGrid

How to include functionality buttons

You can add functionalities to the DataGridProvider including extra buttons that can perform an action according to your requirements. Just need include an IconButton Component from @material-ui and define the icon or button that you need between DataGridProvider tags and specify the action to perform.

The following snippet shows how to include an Add Button:

import * as React from 'react';
import AddIcon from '@material-ui/icons/Add';
import IconButton from '@material-ui/core/IconButton';
import { DataGrid } from 'tubular-react';

const LocalDataGrid = () => (
    <DataGrid columns={columns} dataSource={'https://tubular.azurewebsites.net/api/orders/paged'} gridName="Grid">
        <IconButton color="default" onClick={() => alert('I can help you to add features to your datagrid.')}>
            <AddIcon />
        </IconButton>
    </DataGrid>
);

Run integrated sample

There is a sample included in this project, you can run it just by doing the following.

// Install all the dependencies
npm install
// Run the sample project
npm start

i18n Support

Tubular React now includes a brand new Language Service that will translate the content of the grid to a preferred language.
Devs can also implement content on their language and import it to use this language.
By default, Tubular React comes with implementations in English and Spanish.
If any key content needs parameters to include in the translation, devs can pass the parameters in the translate function.

import { Lang } from 'tubular-react';

Lang.translate('PageNum', 16);
// => 'Page 16'

主要指标

概览
名称与所有者unosquare/tubular-react
主编程语言TypeScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2018-01-15 22:12:45
推送于2022-11-23 19:47:05
最后一次提交2022-11-23 13:49:47
发布数77
最新版本名称v4.2.14 (发布于 )
第一版名称0.3.0 (发布于 )
用户参与
星数206
关注者数24
派生数27
提交数534
已启用问题?
问题数241
打开的问题数0
拉请求数295
打开的拉请求数0
关闭的拉请求数501
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?