tubular-react

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

Github stars Tracking Chart

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'

Main metrics

Overview
Name With Ownerunosquare/tubular-react
Primary LanguageTypeScript
Program languageJavaScript (Language Count: 2)
Platform
License:MIT License
所有者活动
Created At2018-01-15 22:12:45
Pushed At2022-11-23 19:47:05
Last Commit At2022-11-23 13:49:47
Release Count77
Last Release Namev4.2.14 (Posted on )
First Release Name0.3.0 (Posted on )
用户参与
Stargazers Count206
Watchers Count24
Fork Count27
Commits Count534
Has Issues Enabled
Issues Count241
Issue Open Count0
Pull Requests Count295
Pull Requests Open Count0
Pull Requests Close Count501
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private