Code Monkey home page Code Monkey logo

react-datagrid's Introduction

RevoGrid React Adapter

Minimalistic RevoGrid adapter for React.

RevoGrid

Latest Version on NPM Software License

Powerful data grid component built on top of RevoGrid.

Millions of cells and thousands columns easy and efficiently.

Demo and APIKey FeaturesHow To UseDocsLicense

Material grid preview

RevoGrid material theme.

Key Features

  • Millions of cells viewport with a powerful core in-build by default;
  • Keayboard support with excel like focus;
  • Super light initial starter Min size. Can be imported with polifill or as module for modern browsers;
  • Intelligent Virtual DOM and smart row recombination in order to achieve less redraws;
  • Sorting (multiple options, can be customized per column and advanced with events);
  • Filtering
    • Predefined system filters;
    • Preserve existing collection;
    • Custom filters (extend existing system filters with your own set);
  • Export to file;
  • Custom sizes per Column and Row;
  • Column resizing;
  • Autosize support (Column size based on content);
  • Pinned/Sticky/Freezed:
    • Columns (define left or right);
    • Rows (define top or bottom);
  • Grouping:
    • Column grouping (Nester headers);
    • Row grouping (Nested rows);
  • Cell editing;
  • Customizations:
    • Header template;
    • Cell template (build your own cell view);
    • Cell editor (apply your own editors and cell types);
    • Cell properties (build you own properties around rendered cells);
  • Column types;
    • Text/String (default);
    • Number;
    • Select;
    • Date;
    • Custom (take any type as template and create your own extended style);
  • Drag and drop rows;
  • Range operations:
    • Selection;
    • Edit;
  • Theme packages:
    • Excel like (default)
    • Material (compact, dark or light);
  • Copy/Paste (copy/paste from Excel, Google Sheets or any other sheet format);
  • Easy extenation and support with modern VNode features and tsx support;
  • Trimmed rows (hide rows on demand);
  • Plugin system (create your own plugins or extend existing one, it's transparent and easy);
  • Hundred others small customizations and improvements RevoGrid.

How to use

With NPM:

npm i @revolist/react-datagrid --save;

With Yarn:

yarn add @revolist/react-datagrid;
import React from "react";
import { defineCustomElements } from "@revolist/revogrid/loader"; // webcomponent definition loader 
import { RevoGrid } from "@revolist/react-datagrid";

export default class App extends React.Component {
  constructor(props) {
    super(props);
    // you have to define webcomponent before you can use the wrapper
    defineCustomElements();
    this.state = {
      columns: [{ prop: "name" }],
      source: [{ name: "1" }, { name: "2" }]
    };
  }

  afterEdit({ detail }) {}

  render() {
    return (
      <div>
        <RevoGrid
          theme="compact"
          columns={this.state.columns}
          source={this.state.source}
          onAfterEdit={(e) => this.afterEdit(e)}
        />
      </div>
    );
  }
}

Check Sandbox for real live sample.

react-datagrid's People

Contributors

m2a2x avatar revolist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

darkfunction

react-datagrid's Issues

Custom cell renderers written in React

Hi, is there a straightforward way to use React components as cellTemplates?

or are we limited to vanilla html elements / web-components as in the docs?:
https://revolist.github.io/revogrid/guide/cell.renderer.html


I was able to work around this by doing the following:

  class TestElem extends HTMLElement {
    connectedCallback() {
      const mountPoint = document.createElement('span')
      this.attachShadow({ mode: 'open' }).appendChild(mountPoint)
      const value = this.childNodes[0].data
      ReactDOM.render(<SomeComponent value={value}/>, mountPoint)
    }
  }

  customElements.define('test-elem', TestElem)

and if I need access to a redux store, ContextAPI, or other it is possible to create something like this:

const registerComponent = (store) => {
  class TestElem extends HTMLElement {
    connectedCallback() {
      const mountPoint = document.createElement('span')
      this.attachShadow({ mode: 'open' }).appendChild(mountPoint)
      const value = this.childNodes[0].data
      ReactDOM.render(
        <Provider store={store}>
          <SomeComponent value={value}/>
        </Provider>,
        mountPoint,
      )
    }
  }
  customElements.define('test-elem', TestElem)
}

// and when the store is created:
...
registerComponent(store)
...

however, this is not ergonomic at all 😕

do you have plans to facilitate the implementation of react components as cell/header templates?


I think something like this could be a good way to do it, where the web-component definition would be abstracted from the user:

  <RevoGrid
    columns={columns}
    source={data}
    customComponents={{
        'test-elem': TestElem,
        'my-header': MyHeader
    }}
    componentWrappers={
        [StoreWrapper, SomeContext.Provider, etc]
    }
  />

what do you think?

npm package doesn't publish dist directory

Symptom

When trying to import @revolist/revogrid-react, I ran into the following error.

Cannot find module '@revolist/revogrid-react' or its corresponding type declarations.

スクリーンショット 2021-06-11 14 57 50

As far as I investigated, it seems this package doesn't publish dist directory.

// package.json
{
  ...
  "main": "./dist/revogrid.js",
  "module": "./dist/revogrid.js",
  "types": "./dist/revogrid.d.ts",
  ...
}

スクリーンショット 2021-06-11 15 03 26

Expected behavior

This package should publish dist directory.

Could you take care of it, please?

How to embed an SPFx People Picker as a cell?

Hi, I am trying to embed an SPFx People picker as a cell and have created this adapter:

    private peoplePickerAdapter(parent, props) {
        let wrapper;
        if (parent.childNodes.length) {
          wrapper = parent.childNodes[0];
          ReactDOM.unmountComponentAtNode(wrapper);
        } else {
          wrapper = document.createElement("span");
          parent.appendChild(wrapper);
        }
        ReactDOM.render(
        <PeoplePicker 
            context={this.props.context}
            groupName={""}
            showtooltip={false}
            personSelectionLimit={1}
            defaultSelectedUsers={[this.state.picsList[0]]}
            onChange={(items: any[]) => {
                if (items.length != 0) {
                props.model.PICFound.User = items[0];
                } else {
                props.model.PICFound.User = null;
                }
            }}
            principalTypes={[PrincipalType.User]} />
        // <button className='btn btn-primary' style={ {width: "225px"} } type='button' id='btnChangeView' onClick={ async () => { await this.setState( {peopleModalOpen: !this.state.peopleModalOpen} )} } >
        //     {props.model.PICFound.User ? props.model.PICFound.User.Title : "Select PIC"}
        // </button>
        , wrapper);
    }

However, this displays the component but when trying to type in the component it types within the cell. This will not work as the people picker relies on the input of the component to search the users. Is there a way to have the cell level typing turned off and the inputs sent to the component instead of the cell?

The strange thing is that the people picker just doesn't seem to show any sort of data when embeded in the cell.

this is the specific component I'd like to have the functionality of:
https://pnp.github.io/sp-dev-fx-controls-react/controls/PeoplePicker/

I believe an editor is the way however there is not much documentation on the usage of this. Or I am just not experienced enough to implement with the information given. Does anyone know how this could be achieved?

Documentation missing information

Hi, RevoGrid looks cool, and I'm looking to experiment with it.

However, just copying your example from the docs: https://revolist.github.io/revogrid.demo.js/?path=/docs/docs-frameworks-react--page

doesn't yield any result: https://codesandbox.io/s/muddy-dawn-jn9vp?file=/src/Grid.js

It should be clear that we need to execute defineCustomElements for the component to work:

import { defineCustomElements } from '@revolist/revogrid/loader';
defineCustomElements(); // let browser know new component registered

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.