Coder Social home page Coder Social logo

fizix-io / ra-customizable-datagrid Goto Github PK

View Code? Open in Web Editor NEW
71.0 6.0 25.0 7.23 MB

React Admin plugin that allows to hide / show columns dynamically

Home Page: https://fizix-io.github.io/ra-customizable-datagrid/

License: MIT License

JavaScript 100.00%
react-admin react

ra-customizable-datagrid's Introduction

GitHub issues GitHub stars GitHub license Twitter

Fizix logo

ra-customizable-datagrid for React Admin

React Admin plugin that allows to hide / show columns dynamically.

Preview

Demo link

Demo

Features

  • Users can show/hide columns, obviously
  • Users preferences are stored by resource
  • The storage mechanism can be replaced
  • Developers can choose the default visible columns

Installation

ra-customizable-datagrid is available from npm. You can install it (and its required dependencies) using:

$> npm install --save ra-customizable-datagrid

or

$> yarn add ra-customizable-datagrid

Then replace React Admin Datagrid by CustomizableDatagrid

import CustomizableDatagrid from 'ra-customizable-datagrid';

const PostList = props => (
  <List {...props}>
    <CustomizableDatagrid>
      <TextField source="id" />
      <TextField source="title" />
    </CustomizableDatagrid>
  </List>
);

Configuration

Storage

By default LocalStorage is used to store user preferences.

If you need to store them somewhere else, use the storage props like this :

<CustomizableDatagrid storage={CustomStorage}>

where CustomStorage is an object with the set and get methods :

const CustomStorage = {
  get: (resourceName) => /* your own logic here */,
  set: (resourceName, selectedColumns) => /* your own logic here */,
};

Default columns

All the columns are visible by default.

This behavior can be changed with the defaultColumns prop. Just pass an array containing the name of the columns you want to be visible.

import CustomizableDatagrid from 'ra-customizable-datagrid';

const PostList = props => (
  <List {...props}>
    <CustomizableDatagrid defaultColumns={['title']}>
      <TextField source="id" />
      <TextField source="title" />
    </CustomizableDatagrid>
  </List>
);

How to run the demo locally

$> npm run demo-install
$> npm run demo

License

ra-customizable-datagrid is licensed under the MIT License, sponsored and supported by Fizix.

ra-customizable-datagrid's People

Contributors

akselsledins avatar arnaudd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ra-customizable-datagrid's Issues

Outdated dependency on react-admin 2.x

The package.json is out-dated and still requires react-admin 2.x.

"react-admin": "^2.1.1",

There is a react-admin 3.x now. Can you please update to the latest react-admin?

Can't hide/show FunctionFields

If I use a FunctionField in the datagrid, for example:

<FunctionField label="resources.requests.fields.estimate" render={record => "$" + (record.airfare + record.transport + record.hotel + record.meals + record.conf_ticket + record.other)} />

I cannot choose to show/hide this field. Please add support to treat FunctionFields like any column in the table.

Support for translated field names

Does this component support translated labels? I'm using it with a translated admin but on dialog selection field names are not translated.

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.