All Projects → silevis → Reactgrid

silevis / Reactgrid

Licence: mit
Add spreadsheet-like behavior to your React app

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Reactgrid

ag-grid
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
Stars: ✭ 8,743 (+2925.26%)
Mutual labels:  excel, table, datatable, datagrid
React Handsontable
React Data Grid with Spreadsheet Look & Feel. Official React wrapper for Handsontable.
Stars: ✭ 511 (+76.82%)
Mutual labels:  excel, spreadsheet, table, data-table
Nghandsontable
Official AngularJS directive for Handsontable
Stars: ✭ 438 (+51.56%)
Mutual labels:  excel, spreadsheet, table, data-table
Vue Handsontable Official
Vue Data Grid with Spreadsheet Look & Feel. Official Vue wrapper for Handsontable.
Stars: ✭ 751 (+159.86%)
Mutual labels:  excel, spreadsheet, table, datatable
Angular Handsontable
Angular Data Grid with Spreadsheet Look & Feel. Official Angular wrapper for Handsontable.
Stars: ✭ 175 (-39.45%)
Mutual labels:  excel, spreadsheet, table, data-table
Grid
Declarative React Canvas Grid primitive for Data table, Pivot table, Excel Worksheets and more 💥
Stars: ✭ 573 (+98.27%)
Mutual labels:  spreadsheet, table, datagrid, datatable
Datatablesbundle
This Bundle integrates the jQuery DataTables plugin into your Symfony application.
Stars: ✭ 334 (+15.57%)
Mutual labels:  table, datagrid, datatable, data-table
Hot Table
Handsontable - Best Data Grid Web Component with Spreadsheet Look and Feel.
Stars: ✭ 114 (-60.55%)
Mutual labels:  excel, spreadsheet, table, data-table
Tui.grid
🍞🔡 The Powerful Component to Display and Edit Data. Experience the Ultimate Data Transformer!
Stars: ✭ 1,859 (+543.25%)
Mutual labels:  excel, spreadsheet, datagrid, datatable
Ce
Jspreadsheet is a lightweight vanilla javascript plugin to create amazing web-based interactive tables and spreadsheets compatible with other spreadsheet software.
Stars: ✭ 5,832 (+1917.99%)
Mutual labels:  excel, spreadsheet, table
Sheetjs
📗 SheetJS Community Edition -- Spreadsheet Data Toolkit
Stars: ✭ 28,479 (+9754.33%)
Mutual labels:  excel, spreadsheet, table
React Spreadsheet Grid
An Excel-like grid component for React with custom cell editors, performant scroll & resizable columns
Stars: ✭ 996 (+244.64%)
Mutual labels:  excel, spreadsheet, table
React Table
⚛️ Hooks for building fast and extendable tables and datagrids for React
Stars: ✭ 15,739 (+5346.02%)
Mutual labels:  table, datagrid, datatable
Luckysheet
Luckysheet is an online spreadsheet like excel that is powerful, simple to configure, and completely open source.
Stars: ✭ 9,772 (+3281.31%)
Mutual labels:  excel, spreadsheet, data-table
Functional Data Grid
Data grids in functional style with ReactJS
Stars: ✭ 125 (-56.75%)
Mutual labels:  excel, spreadsheet, datagrid
Handsontable
JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡
Stars: ✭ 16,059 (+5456.75%)
Mutual labels:  excel, spreadsheet, data-table
react-bolivianite-grid
React grid component for virtualized rendering large tabular data.
Stars: ✭ 95 (-67.13%)
Mutual labels:  table, spreadsheet, data-table
Datatable
A simple, modern and interactive datatable library for the web
Stars: ✭ 587 (+103.11%)
Mutual labels:  table, datagrid, datatable
Ka Table
Lightweight MIT React Table component for both TS and JS with Sorting, Filtering, Grouping, Virtualization, Editing and many more
Stars: ✭ 117 (-59.52%)
Mutual labels:  table, datagrid, datatable
svelte-datagrid
Svelte data grid spreadsheet best best features and performance from excel
Stars: ✭ 48 (-83.39%)
Mutual labels:  spreadsheet, datatable, datagrid

ReactGrid MIT

Add spreadsheet-like behavior to your React app 🚀

MIT license Build Status reactgrid

MIT license npm version

Sample app

Browse our examples & docs: 👉 reactgrid.com

Before running ReactGrid you need to have installed:

  • react": "^16.13.1"
  • react-dom: "^16.13.1"

Install

npm i @silevis/reactgrid

Usage

In this particullar example we will display data in the same way like in a standard datatable. Of course you can still place yours cells anywhere, but now we will focus on the basics.

Import ReactGrid component

import { ReactGrid, Column, Row } from "@silevis/reactgrid";

Import CSS styles

Import basic CSS styles. This file is necessary to correctly display ReactGrid.

import "@silevis/reactgrid/styles.css";

Create a cell matrix

It's a good idea to separate up our data (people list) from ReactGrid interface (especially Row and Column). We encourage you to use Typescript features to prevent you from the possibly inconsistent data.

interface Person {
  name: string;
  surname: string;
}

const getPeople = (): Person[] => [
  { name: "Thomas", surname: "Goldman" },
  { name: "Susie", surname: "Quattro" },
  { name: "", surname: "" }
];

In the next step we have defined an array of ReactGrid's Columns stored in getColumns function. If you are interested how to do more complex operations related with columns like resizing or reordering, please browse our 👉 docs

const getColumns = (): Column[] => [
  { columnId: "name", width: 150 },
  { columnId: "surname", width: 150 }
];

At the top of the datatable we are going to display static cells that contain Name and Surname so we can define them now.

const headerRow: Row<HeaderCell> = {
  rowId: "header",
  cells: [
    { type: "header", text: "Name" },
    { type: "header", text: "Surname" }
  ]
};

ReactGrid rows prop expects an array of rows that are compatible with imported Rows interface. As you see the function returns the header row and mapped people array to ReactGrid's Rows.

const getRows = (people: Person[]): Row[] => [
  headerRow,
  ...people.map<Row>((person, idx) => ({
    rowId: idx,
    cells: [
      { type: "text", text: person.name },
      { type: "text", text: person.surname }
    ]
  }))
];

The last step is wrapping it all up in the App component. People were stored inside people variable as React hook. ReactGrid component was fed with generated rows structure and previously defined columns

function App() {
  const [people] = React.useState<Person[]>(getPeople());
  
  const rows = getRows(people);
  const columns = getColumns();

  return <ReactGrid rows={rows} columns={columns} />;
}

Open live demo on codesandbox.io

Handling changes

Our code is currently read-only. To be able to change any value inside the grid you have to implement your own handler.

Let's start with updating imports:

import { ReactGrid, Column, Row, CellChange, TextCell} from "@silevis/reactgrid";

Then define the function that applies changes to data and returns its copy. We expect that incoming changes affect TextCell, so the changes were marked by a following interface: CellChange<TextCell>[]. Given that information, we find the row and the column affected by each change, and then replace an appropriate cell text with a new one.

const applyChangesToPeople = (
  changes: CellChange<TextCell>[],
  prevPeople: Person[]
): Person[] => {
  changes.forEach((change) => {
    const personIndex = change.rowId;
    const fieldName = change.columnId;
    prevPeople[personIndex][fieldName] = change.newCell.text;
  });
  return [...prevPeople];
};

It's time to update the App component. As you see the handleChanges function updates only data by setting updated people from applyChangesToPeople function.

function App() {
  const [people, setPeople] = React.useState<Person[]>(getPeople());

  const rows = getRows(people);
  const columns = getColumns();

  const handleChanges = (changes: CellChange<TextCell>[]) => {
    setPeople((prevPeople) => applyChangesToPeople(changes, prevPeople));
  };

  return (
    <ReactGrid rows={rows} columns={columns} onCellsChanged={handleChanges} />
  );
}

Open live demo on codesandbox.io

Other examples:

Browser support

Edge Edge Firefox Firefox Chrome Chrome Safari Safari iOS Safari iOS/iPadOs Safari Samsung Samsung internet Opera Opera
80+ 61+ 57+ 13.1+ 13+ 9+ 45+

Docs

Explore ReactGrid docs: here

Licensing

ReactGrid is available in two versions, MIT (this package) which serve the full interface but is limited in functionality and PRO which is a fully functional version. You can compare versions here.

(c) 2020 Silevis Software Sp. z o.o.

Authors

Silevis Software

Silevis

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].