1.0.30 • Published 1 year ago

extended-mui-data-grid v1.0.30

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Extended MUI Data Grid

This library contains an extended version of the MUI X Data Grid that includes custom implementations of some of the paid features so that they can be used for free. All of these extended features are 100% opt in, and by default the <ExtendedDataGrid /> component will function identically to the out-of-the-box MUI X <DataGrid />.

Supported Paid Features

comparable MUI X feature

import { ExtendedDataGrid } from "extended-mui-data-grid";

const data = new Array(100).fill(null).map((_, idx) => ({
  name: `Column ${idx}`,
  someOtherField: `Value ${idx % 13}`,
  id: `${idx}`,
}));

const MyComponent: FC = () => {
  return (
    <ExtendedDataGrid
      rows={data}
      columns={[
        { field: "id" },
        { field: "name", sortable: true },
        { field: "someOtherField", sortable: true },
      ]}
    />
  );
};

comparable MUI X feature

import { ExtendedDataGrid } from "extended-mui-data-grid";

const data = new Array(100).fill(null).map((_, idx) => ({
  name: `Column ${idx}`,
  someOtherField: `Value ${idx % 13}`,
  id: `${idx}`,
}));

const MyComponent: FC = () => {
  return (
    <ExtendedDataGrid
      rows={data}
      columns={[
        { field: "id" },
        { field: "name", filterable: true },
        { field: "someOtherField", filterable: true },
      ]}
    />
  );
};

comparable MUI X feature

Currently only supports single row selection/copying.

import { ExtendedDataGrid, serializeRow } from "extended-mui-data-grid";

const data = new Array(100).fill(null).map((_, idx) => ({
  name: `Column ${idx}`,
  someOtherField: `Value ${idx % 13}`,
  id: `${idx}`,
}));

const MyComponent: FC = () => {
  return (
    <ExtendedDataGrid
      enableRowCopy
      onRowsCopied={(rows, serializedRows) => alert(serializedRows)}
      /**
       * optional, can use a custom serializing function to convert the selected
       * row(s) to a string. The default function (serializeRow) will convert the
       * row(s) to a csv-like string.
       */
      serializeRow={(row, idx) => serializeRow(row, idx)}
      rows={data}
      columns={[
        { field: "id" },
        { field: "name" },
        { field: "someOtherField" },
      ]}
    />
  );
};

comparable MUI X feature

Currently only supports full new row pasting, not pasting edits into an existing row

import { ExtendedDataGrid, serializeRow } from "extended-mui-data-grid";

const data = new Array(100).fill(null).map((_, idx) => ({
  name: `Column ${idx}`,
  someOtherField: `Value ${idx % 13}`,
  id: `${idx}`,
}));

const MyComponent: FC = () => {
  const [rows, setRows] = useState(data);

  return (
    <ExtendedDataGrid
      enableRowCopy
      enableRowPaste
      onValidRowsPasted={(newRows) => {
        // presumably this gets sent to an api
        const savedRows = newRows.map((r) => ({ ...r, id: Math.random() }));
        setRows([...rows, ...savedRows]);
        return Promise.resolve(savedRows);
      }}
      onRowsCopied={(rows, serializedRows) => alert(serializedRows)}
      rows={rows}
      columns={[
        { field: "id" },
        { field: "name" },
        { field: "someOtherField" },
      ]}
    />
  );
};

Properties

Unless otherwise specified, <ExtendedDataGrid /> supports all of the same props that the base <DataGrid /> accepts.

Disabled Base <DataGrid /> Props

Prop
sortModel
sortingOrder
sortingMode
onSortModelChange

Additional <ExtendedDataGrid /> Props

PropDefaultDescription
enableRowCopyfalseIf true, the selected row will be copied to the user's clipboard when ctrl+c is pressed
serializeRowspapaparse.unparseWhen copying row(s), this function is ran to serialize the data to a string
onRowsCopiedCallback called after rows are copied with the raw and serialized data
enableClipboardPastefalseIf true, clipboard data will be attempted to be inserted into the table when ctrl+v is pressed
deserializeRowspapaparse.parseWhen pasting row(s), this function is ran to attempt to deserialize string data into the table row data format
validateDeserializedRows() => trueWhen pasting row(s), this function is ran after deserializing clipboard data. If it returns true the data will be added into the table
onValidRowsPastedrequired if enableClipboardPaste = trueWhen pasting row(s), this function is ran after the deserialized clipboard data is validated. Pasted rows aren't directly added to the table, use this function to add the new rows into the table state in whatever manner is appropriate.
onRowPasteValidationFailedWhen pasting row(s), if validateDeserializedRows returns false, this function is called with the deserialized data.
1.0.2

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.30

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago