Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Add column filter support #380

Closed
wants to merge 3 commits into from

Conversation

dtassone
Copy link
Member

@dtassone dtassone commented Sep 30, 2020

Related to #201

@dtassone dtassone marked this pull request as draft September 30, 2020 17:12
enabled: true,
boundariesElement: 'scrollParent',
},
// arrow: {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't get this to work properly

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why display an arrow? They are never present in Material Design.

Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have linked #201 in the issue description, added two new benchmark links, and added a screenshot for all the links showcasing the approach used for filtering.

It seems that we could consider the following:

  • A filtering API, on the data only (headless)
  • A quick column filter (quick filter but for each column)
  • A menu column menu filter with or/and aggregation and operators (>, <, ==, etc.), Excel-like

Capture d’écran 2020-10-01 à 00 46 04

  • A chip to display the active filters, Google Ads like

@@ -11,4 +11,9 @@ export const ArrowDownwardIcon = createSvgIcon(
'ArrowDownward',
);

export const FilterIcon = createSvgIcon(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should retain the original name. At the minimum to remove any discussion around best naming, and at best, to keep the reference to the original icon, in case somebody looking in the source want to find it from @material-ui/icons or if the material design icon updates in the future.

Suggested change
export const FilterIcon = createSvgIcon(
export const FilterListIcon = createSvgIcon(

enabled: true,
boundariesElement: 'scrollParent',
},
// arrow: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why display an arrow? They are never present in Material Design.

Comment on lines 183 to 191
disablePortal={false}
modifiers={{
flip: {
enabled: true,
},
preventOverflow: {
enabled: true,
boundariesElement: 'scrollParent',
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried with the default options?

Suggested change
disablePortal={false}
modifiers={{
flip: {
enabled: true,
},
preventOverflow: {
enabled: true,
boundariesElement: 'scrollParent',
},

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum not sure, I forgot we are using Material-UI v4 and not v5!

[colDef],
);

const onFilterChange = React.useCallback((event) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TextField doesn't use memo. I believe that the best way to handle performance is to only consider it once an issue Is measured. Why bother using useCallback here?

Suggested change
const onFilterChange = React.useCallback((event) => {
const onFilterChange = (event) => {

const [isOpen, setIsOpen] = React.useState(false);
const [filterValue, setFilterValue] = React.useState('');
const [target, setTarget] = React.useState<HTMLElement | null>(null);
const [colDef, setColumn] = React.useState<ColDef | null>(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency:

Suggested change
const [colDef, setColumn] = React.useState<ColDef | null>(null);
const [colDef, setColDef] = React.useState<ColDef | null>(null);

or

Suggested change
const [colDef, setColumn] = React.useState<ColDef | null>(null);
const [column, setColumn] = React.useState<ColDef | null>(null);


return (
<div className={'MuiDataGrid-iconFilter'}>
<IconButton aria-label="Sort" size="small" onClick={filterClick}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<IconButton aria-label="Sort" size="small" onClick={filterClick}>
<IconButton aria-label="filter" size="small" onClick={filterClick}>

Comment on lines 59 to 60
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard coded ids

Comment on lines 223 to 225
<IconButton color="primary" aria-label="Filter" component="span">
<Search />
</IconButton>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered using a regular button instead? I was confused about the icon, I thought it was a presentational one.

)}
</div>
{!isColumnNumeric && (
<>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<>
<React.Fragment>

hide={column.hideSortIcons}
/>
{isColumnNumeric && <ColumnHeaderFilterIcon column={column} />}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@oliviertassinari oliviertassinari changed the title [DataGrid] Add Column Filter component [DataGrid] Add column filter support Oct 7, 2020
@dtassone dtassone closed this Oct 30, 2020
@oliviertassinari oliviertassinari added the component: data grid This is the name of the generic UI component, not the React module! label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants