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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?