Git Product home page Git Product logo

ra-datagrid's Introduction

ra-datagrid

Integration of Material-ui's <Datagrid> into react-admin.

ra-datagrid.mp4

Features

  • Server-side filtering, sorting and pagination via the dataProvider
  • Row selection
  • Cell editing
  • Hide / show columns
  • All the material-ui <Datagrid> features (additional props are passed down to it)

Usage

Replace react-admin's <Datagrid> by the one exported by this package. Make sure you set pagination={false} on the list as the Datagrid embarks its own pagination.

import { List } from "react-admin";
import { GridColDef, GridValueGetterParams } from "@material-ui/data-grid";
import { Datagrid, simpleFilterOperator } from "ra-datagrid";

const columns: GridColDef[] = [
  {
    field: "id",
    headerName: "Id",
    type: "string",
    width: 100,
    disableClickEventBubbling: true,
    filterOperators: simpleFilterOperator,
  },
  {
    field: "last_name",
    headerName: "Full name",
    description: "This column has a value getter and is not sortable.",
    sortable: true,
    flex: 1,
    valueGetter: (params: GridValueGetterParams) =>
      `${params.row.first_name || ""} ${params.row.last_name || ""}`,
    disableClickEventBubbling: true,
  },
  {
    field: "last_seen",
    headerName: "Last seen",
    type: "date",
    valueGetter: (params: GridValueGetterParams) =>
      new Date(params.row.last_seen || ""),
    width: 160,
    disableClickEventBubbling: true,
    editable: true,
    filterOperators: simpleFilterOperator,
  },
  {
    field: "total_spent",
    headerName: "Spent",
    type: "number",
    width: 150,
    disableClickEventBubbling: true,
    editable: true,
    filterOperators: simpleFilterOperator,
  },
];

export const CustomerList = (props: any) => (
  <List {...props} pagination={false}>
    <Datagrid columns={columns} />
  </List>
);

Contributing

## install dependencies for core package and example
yarn install
## build JS from ts
yarn build
## run example
yarn start

License

MIT, sponsored by marmelab

ra-datagrid's People

Contributors

fzaninotto 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

Watchers

 avatar  avatar  avatar

Forkers

wixsl pi6eon

ra-datagrid's Issues

Show empty header

Hello.
Is it possible to add option to display empty table header ?

if (loaded && (ids.length === 0 || total === 0) && !showEmptyHeader) {
        if (empty) {
            return empty;
        }

        return null;
    }

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.