4.1.1 • Published 1 month ago

data-grid-ultra v4.1.1

Weekly downloads
-
License
Unlicense
Repository
github
Last release
1 month ago

data-grid-ultra

This package is a full customized data grid component base on mui data grid library.

Buy me a coffee

Installation

Install the package in your project directory with:

npm install data-grid-ultra

Usage

import * as React from 'react';
import Box from '@mui/material/Box';
import {
  DataGridUltra,
  GridToolbar,
  useGridApiRef,
  useKeepGroupedColumnsHidden,
} from 'data-grid-ultra';
import { useDemoData } from '@mui/x-data-grid-generator';

export default function DataGridUltraDemo() {
  const { data, loading } = useDemoData({
    dataSet: 'Commodity',
    rowLength: 100,
    editable: true,
    visibleFields: [
      'commodity',
      'quantity',
      'filledQuantity',
      'status',
      'isFilled',
      'unitPrice',
      'unitPriceCurrency',
      'subTotal',
      'feeRate',
      'feeAmount',
      'incoTerm',
    ],
  });
  const apiRef = useGridApiRef();

  const initialState = useKeepGroupedColumnsHidden({
    apiRef,
    initialState: {
      ...data.initialState,
      rowGrouping: {
        ...data.initialState?.rowGrouping,
        model: ['commodity'],
      },
      sorting: {
        sortModel: [{ field: '__row_group_by_columns_group__', sort: 'asc' }],
      },
    },
  });

  return (
    <Box sx={{ height: 520, width: '100%' }}>
      <DataGridUltra
        {...data}
        apiRef={apiRef}
        loading={loading}
        disableRowSelectionOnClick
        initialState={initialState}
        slots={{ toolbar: GridToolbar }}
      />
    </Box>
  );
}

Props

NameTypeDefaultDescription
columns*Array<object>-Set of columns of type GridColDef[].
aggregationFunctionsobjectGRID_AGGREGATION_FUNCTIONSAggregation functions available on the grid.
aggregationModelobject-Set the aggregation model of the grid.
aggregationRowsScope'all' | 'filtered'"filtered"Rows used to generate the aggregated value. If filtered, the aggregated values are generated using only the rows currently passing the filtering process. If all, the aggregated values are generated using all the rows.
apiRef{ current: object }-The ref object that allows grid manipulation. Can be instantiated with useGridApiRef().
aria-labelstring-The label of the Data Grid.
aria-labelledbystring-The id of the element containing a label for the Data Grid.
autoHeightboolfalseIf true, the Data Grid height is dynamic and follow the number of rows in the Data Grid.
autoPageSizeboolfalseIf true, the pageSize is calculated according to the container size and the max number of rows to avoid rendering a vertical scroll bar.
autosizeOnMountboolfalseIf true, columns are autosized after the datagrid is mounted.
autosizeOptions{ columns?: Array<string>, expand?: bool, includeHeaders?: bool, includeOutliers?: bool, outliersFactor?: number }-The options for autosize when user-initiated.
cellModesModelobject-Controls the modes of the cells.
cellSelectionboolfalseIf true, the cell selection mode is enabled.
cellSelectionModelobject-Set the cell selection model of the grid.
checkboxSelectionboolfalseIf true, the Data Grid will display an extra column with checkboxes for selecting rows.
checkboxSelectionVisibleOnlyboolfalseIf true, the "Select All" header checkbox selects only the rows on the current page. To be used in combination with checkboxSelection. It only works if the pagination is enabled.
classesobject-Override or extend the styles applied to the component.See CSS classes API below for more details.
clipboardCopyCellDelimiterstring' 'The character used to separate cell values when copying to the clipboard.
columnBufferPxnumber150Column region in pixels to render before/after the viewport
columnHeaderHeightnumber56Sets the height in pixel of the column headers in the Data Grid.
columnVisibilityModelobject-Set the column visibility model of the Data Grid. If defined, the Data Grid will ignore the hide property in GridColDef.
defaultGroupingExpansionDepthnumber0If above 0, the row children will be expanded up to this depth. If equal to -1, all the row children will be expanded.
density'comfortable' | 'compact' | 'standard'"standard"Set the density of the Data Grid.
detailPanelExpandedRowIdsArray<number | string>-The row ids to show the detail panel.
disableAggregationboolfalseIf true, aggregation is disabled.
disableAutosizeboolfalseIf true, column autosizing on header separator double-click is disabled.
disableChildrenFilteringboolfalseIf true, the filtering will only be applied to the top level rows when grouping rows with the treeData prop.
disableChildrenSortingboolfalseIf true, the sorting will only be applied to the top level rows when grouping rows with the treeData prop.
disableClipboardPasteboolfalseIf true, the clipboard paste is disabled.
disableColumnFilterboolfalseIf true, column filters are disabled.
disableColumnMenuboolfalseIf true, the column menu is disabled.
disableColumnPinningboolfalseIf true, the column pinning is disabled.
disableColumnReorderboolfalseIf true, reordering columns is disabled.
disableColumnResizeboolfalseIf true, resizing columns is disabled.
disableColumnSelectorboolfalseIf true, hiding/showing columns is disabled.
disableColumnSortingboolfalseIf true, the column sorting feature will be disabled.
disableDensitySelectorboolfalseIf true, the density selector is disabled.
disableEvalboolfalseIf true, eval() is not used for performance optimization.
disableMultipleColumnsFilteringboolfalseIf true, filtering with multiple columns is disabled.
disableMultipleColumnsSortingboolfalseIf true, the sorting with multiple columns is disabled.
disableMultipleRowSelectionboolfalse (!props.checkboxSelection for MIT Data Grid)If true, multiple selection using the Ctrl/CMD or Shift key is disabled. The MIT DataGrid will ignore this prop, unless checkboxSelection is enabled.
disableRowGroupingboolfalseIf true, the row grouping is disabled.
disableRowSelectionOnClickboolfalseIf true, the selection on click on a row or cell is disabled.
disableVirtualizationboolfalseIf true, the virtualization is disabled.
editMode'cell' | 'row'"cell"Controls whether to use the cell or row editing.
experimentalFeatures{ warnIfFocusStateIsNotSynced?: bool }-Unstable features, breaking changes might be introduced. For each feature, if the flag is not explicitly set to true, then the feature is fully disabled, and neither property nor method calls will have any effect.
filterDebounceMsnumber150The milliseconds delay to wait after a keystroke before triggering filtering.
filterMode'client' | 'server'"client"Filtering can be processed on the server or client-side. Set it to 'server' if you would like to handle filtering on the server-side.
filterModel{ items: Array<{ field: string, id?: number | string, operator: string, value?: any }>, logicOperator?: 'and' | 'or', quickFilterExcludeHiddenColumns?: bool, quickFilterLogicOperator?: 'and' | 'or', quickFilterValues?: array }-Set the filter model of the Data Grid.
getAggregationPositionfunc(groupNode) => groupNode == null ? 'footer' : 'inline'Determines the position of an aggregated value.Signature:function(groupNode: GridGroupNode) => GridAggregationPositionnullgroupNode The current group.Returns: Position of the aggregated value (if null, the group isn't aggregated).
getCellClassNamefunc-Function that applies CSS classes dynamically on cells.Signature:function(params: GridCellParams) => stringparams With all properties from GridCellParams.Returns: The CSS class to apply to the cell.
getDetailPanelContentfunc-Function that returns the element to render in row detail.Signature:function(params: GridRowParams) => React.JSX.Elementparams With all properties from GridRowParams.Returns: The row detail element.
getDetailPanelHeightfunc"() => 500"Function that returns the height of the row detail panel.Signature:function(params: GridRowParams) => numberstringparams With all properties from GridRowParams.Returns: The height in pixels or "auto" to use the content height.
getEstimatedRowHeightfunc-Function that returns the estimated height for a row. Only works if dynamic row height is used. Once the row height is measured this value is discarded.Signature:function(params: GridRowHeightParams) => numbernullparams With all properties from GridRowHeightParams.Returns: The estimated row height value. If null or undefined then the default row height, based on the density, is applied.
getRowClassNamefunc-Function that applies CSS classes dynamically on rows.Signature:function(params: GridRowClassNameParams) => stringparams With all properties from GridRowClassNameParams.Returns: The CSS class to apply to the row.
getRowHeightfunc-Function that sets the row height per row.Signature:function(params: GridRowHeightParams) => GridRowHeightReturnValueparams With all properties from GridRowHeightParams.Returns: The row height value. If null or undefined then the default row height is applied. If "auto" then the row height is calculated based on the content.
getRowIdfunc-Return the id of a given GridRowModel.
getRowSpacingfunc-Function that allows to specify the spacing between rows.Signature:function(params: GridRowSpacingParams) => GridRowSpacingparams With all properties from GridRowSpacingParams.Returns: The row spacing values.
getTreeDataPathfunc-Determines the path of a row in the tree data. For instance, a row with the path "A", "B" is the child of the row with the path "A". Note that all paths must contain at least one element.Signature:function(row: R) => Arrayrow The row from which we want the path.Returns: The path to the row.
groupingColDeffunc | object-The grouping column used by the tree data.
headerFiltersboolfalseIf true, enables the data grid filtering on header feature.
hideFooterboolfalseIf true, the footer component is hidden.
hideFooterPaginationboolfalseIf true, the pagination component in the footer is hidden.
hideFooterRowCountboolfalseIf true, the row count in the footer is hidden. It has no effect if the pagination is enabled.
hideFooterSelectedRowCountboolfalseIf true, the selected row count in the footer is hidden.
ignoreDiacriticsboolfalseIf true, the diacritics (accents) are ignored when filtering or quick filtering. E.g. when filter value is cafe, the rows with café will be visible.
ignoreValueFormatterDuringExport{ clipboardExport?: bool, csvExport?: bool } | boolfalseIf true, the Data Grid will not use valueFormatter when exporting to CSV or copying to clipboard. If an object is provided, you can choose to ignore the valueFormatter for CSV export or clipboard export.
initialStateobject-The initial state of the DataGridPremium. The data in it is set in the state on initialization but isn't controlled. If one of the data in initialState is also being controlled, then the control state wins.
isCellEditablefunc-Callback fired when a cell is rendered, returns true if the cell is editable.Signature:function(params: GridCellParams) => booleanparams With all properties from GridCellParams.Returns: A boolean indicating if the cell is editable.
isGroupExpandedByDefaultfunc-Determines if a group should be expanded after its creation. This prop takes priority over the defaultGroupingExpansionDepth prop.Signature:function(node: GridGroupNode) => booleannode The node of the group to test.Returns: A boolean indicating if the group is expanded.
isRowSelectablefunc-Determines if a row can be selected.Signature:function(params: GridRowParams) => booleanparams With all properties from GridRowParams.Returns: A boolean indicating if the cell is selectable.
keepColumnPositionIfDraggedOutsideboolfalseIf true, moving the mouse pointer outside the grid before releasing the mouse button in a column re-order action will not cause the column to jump back to its original position.
keepNonExistentRowsSelectedboolfalseIf true, the selection model will retain selected rows that do not exist. Useful when using server side pagination and row selections need to be retained when changing pages.
loadingbool-If true, a loading overlay is displayed.
localeTextobject-Set the locale text of the Data Grid. You can find all the translation keys supported in the source in the GitHub repository.
logger{ debug: func, error: func, info: func, warn: func }consolePass a custom logger in the components that implements the Logger interface.
logLevel'debug' | 'error' | 'info' | 'warn' | false"error" ("warn" in dev mode)Allows to pass the logging level or false to turn off logging.
noncestring-Nonce of the inline styles for Content Security Policy.
onAggregationModelChangefunc-Callback fired when the row grouping model changes.Signature:function(model: GridAggregationModel, details: GridCallbackDetails) => voidmodel The aggregated columns.details Additional details for this callback.
onBeforeClipboardPasteStartfunc-Callback fired before the clipboard paste operation starts. Use it to confirm or cancel the paste operation.Signature:function(params: object) => voidparams Params passed to the callback.
onCellClickfunc-Callback fired when any cell is clicked.Signature:function(params: GridCellParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridCellParams.event The event object.details Additional details for this callback.
onCellDoubleClickfunc-Callback fired when a double click event comes from a cell element.Signature:function(params: GridCellParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridCellParams.event The event object.details Additional details for this callback.
onCellEditStartfunc-Callback fired when the cell turns to edit mode.Signature:function(params: GridCellParams, event: MuiEvent) => voidparams With all properties from GridCellParams.event The event that caused this prop to be called.
onCellEditStopfunc-Callback fired when the cell turns to view mode.Signature:function(params: GridCellParams, event: MuiEvent) => voidparams With all properties from GridCellParams.event The event that caused this prop to be called.
onCellKeyDownfunc-Callback fired when a keydown event comes from a cell element.Signature:function(params: GridCellParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridCellParams.event The event object.details Additional details for this callback.
onCellModesModelChangefunc-Callback fired when the cellModesModel prop changes.Signature:function(cellModesModel: GridCellModesModel, details: GridCallbackDetails) => voidcellModesModel Object containing which cells are in "edit" mode.details Additional details for this callback.
onCellSelectionModelChangefunc-Callback fired when the selection state of one or multiple cells changes.Signature:function(cellSelectionModel: GridCellSelectionModel, details: GridCallbackDetails) => voidcellSelectionModel Object in the shape of GridCellSelectionModel containing the selected cells.details Additional details for this callback.
onClipboardCopyfunc-Callback called when the data is copied to the clipboard.Signature:function(data: string) => voiddata The data copied to the clipboard.
onClipboardPasteEndfunc-Callback fired when the clipboard paste operation ends.
onClipboardPasteStartfunc-Callback fired when the clipboard paste operation starts.
onColumnHeaderClickfunc-Callback fired when a click event comes from a column header element.Signature:function(params: GridColumnHeaderParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridColumnHeaderParams.event The event object.details Additional details for this callback.
onColumnHeaderDoubleClickfunc-Callback fired when a double click event comes from a column header element.Signature:function(params: GridColumnHeaderParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridColumnHeaderParams.event The event object.details Additional details for this callback.
onColumnHeaderEnterfunc-Callback fired when a mouse enter event comes from a column header element.Signature:function(params: GridColumnHeaderParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridColumnHeaderParams.event The event object.details Additional details for this callback.
onColumnHeaderLeavefunc-Callback fired when a mouse leave event comes from a column header element.Signature:function(params: GridColumnHeaderParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridColumnHeaderParams.event The event object.details Additional details for this callback.
onColumnHeaderOutfunc-Callback fired when a mouseout event comes from a column header element.Signature:function(params: GridColumnHeaderParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridColumnHeaderParams.event The event object.details Additional details for this callback.
onColumnHeaderOverfunc-Callback fired when a mouseover event comes from a column header element.Signature:function(params: GridColumnHeaderParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridColumnHeaderParams.event The event object.details Additional details for this callback.
onColumnOrderChangefunc-Callback fired when a column is reordered.Signature:function(params: GridColumnOrderChangeParams, event: MuiEvent<{}>, details: GridCallbackDetails) => voidparams With all properties from GridColumnOrderChangeParams.event The event object.details Additional details for this callback.
onColumnResizefunc-Callback fired while a column is being resized.Signature:function(params: GridColumnResizeParams, event: MuiEvent, details: GridCallbackDetails) => voidparams With all properties from GridColumnResizeParams.event The event object.details Additional details for this callback.