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] Filtering performance: V7 API #9254

Merged
merged 46 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fb1ea84
perf: v7 filters
romgrk Jun 7, 2023
9830c58
lint
romgrk Jun 7, 2023
9608d9d
fix: aggregation filtering
romgrk Jun 7, 2023
fad4bb2
lint
romgrk Jun 7, 2023
030f2a5
fix: some tests
romgrk Jun 7, 2023
1b063cb
Merge branch 'master' into perf-filtering-v7-filters
romgrk Jun 9, 2023
64ba858
fix: some tests
romgrk Jun 9, 2023
2c4d970
fix: rows list
romgrk Jun 9, 2023
40e05b4
fix: quickfilter
romgrk Jun 9, 2023
c24143a
lint
romgrk Jun 9, 2023
e8a8aec
lint
romgrk Jun 9, 2023
a7483b4
lint
romgrk Jun 9, 2023
6fd694f
lint
romgrk Jun 9, 2023
d1be29a
fix: restore column fields
romgrk Jun 12, 2023
3e0a6bc
Merge branch 'master' into perf-filtering-v7-filters
romgrk Jun 14, 2023
b04cb1e
refactor
romgrk Jun 14, 2023
f7cb7b6
docs
romgrk Jun 14, 2023
9fdbe9a
lint
romgrk Jun 14, 2023
5706be9
doc: update
romgrk Jun 14, 2023
3a084e6
doc
romgrk Jun 14, 2023
03e6cd8
Update docs/data/data-grid/filtering/customization.md
romgrk Jun 14, 2023
c66cd40
Update docs/data/data-grid/filtering/customization.md
romgrk Jun 14, 2023
adc8027
fix: missed v7 refactor
romgrk Jun 14, 2023
6223641
Merge branch 'perf-filtering-v7-filters' of github.com:romgrk/mui-x i…
romgrk Jun 14, 2023
f7b30d4
refactor: typings
romgrk Jun 14, 2023
f7b19c6
lint
romgrk Jun 14, 2023
6f5fb73
lint
romgrk Jun 14, 2023
c285417
Merge branch 'master' into perf-filtering-v7-filters
romgrk Jun 20, 2023
1372ed9
refactor: compatibility changes
romgrk Jun 20, 2023
08a3223
doc: update
romgrk Jun 20, 2023
d59889f
lint
romgrk Jun 20, 2023
5c26f45
lint
romgrk Jun 20, 2023
343c385
lint
romgrk Jun 20, 2023
c9146f5
lint
romgrk Jun 21, 2023
dca10c7
fix: quickfilter compatibility
romgrk Jun 21, 2023
cde04ba
lint
romgrk Jun 21, 2023
ff9d602
Update packages/grid/x-data-grid/src/models/api/gridParamsApi.ts
romgrk Jun 21, 2023
441ee98
Update packages/grid/x-data-grid/src/models/api/gridParamsApi.ts
romgrk Jun 21, 2023
3eb9812
lint
romgrk Jun 28, 2023
2dda132
refactor
romgrk Jun 28, 2023
725139e
test: add v7 compat
romgrk Jun 28, 2023
2c6f402
Merge branch 'perf-filtering-v7-filters' of github.com:romgrk/mui-x i…
romgrk Jun 28, 2023
0af6482
test: add v7 qf tests
romgrk Jun 28, 2023
3cbac8f
lint
romgrk Jun 28, 2023
52482e5
lint
romgrk Jun 28, 2023
ffa0250
docs: api
romgrk Jun 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: quickfilter compatibility
  • Loading branch information
romgrk committed Jun 21, 2023
commit dca10c76e7c37024111aa498bd4f044470c2d33e
6 changes: 3 additions & 3 deletions packages/grid/x-data-grid/src/colDef/gridNumericOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { GridFilterInputValue } from '../components/panel/filterPanel/GridFilter
import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
import { GridFilterOperator } from '../models/gridFilterOperator';
import type { GridApplyQuickFilterV7 } from '../models/colDef/gridColDef';
import { convertLegacyOperators } from './utils';
import { convertLegacyOperators, tagInternalFilter } from './utils';

const parseNumericValue = (value: unknown) => {
if (value == null) {
Expand All @@ -12,15 +12,15 @@ const parseNumericValue = (value: unknown) => {
return Number(value);
};

export const getGridNumericQuickFilterFn = (value: any): GridApplyQuickFilterV7 | null => {
export const getGridNumericQuickFilterFn = tagInternalFilter((value: any): GridApplyQuickFilterV7 | null => {
if (value == null || Number.isNaN(value) || value === '') {
return null;
}

return (columnValue): boolean => {
return parseNumericValue(columnValue) === parseNumericValue(value);
};
};
});

export const getGridNumericOperators = (): GridFilterOperator<any, number | string | null, any>[] =>
convertLegacyOperators([
Expand Down
6 changes: 3 additions & 3 deletions packages/grid/x-data-grid/src/colDef/gridStringOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import type { GridApplyQuickFilterV7 } from '../models/colDef/gridColDef';
import { GridFilterItem } from '../models/gridFilterItem';
import { GridFilterOperator } from '../models/gridFilterOperator';
import { GridFilterInputMultipleValue } from '../components/panel/filterPanel/GridFilterInputMultipleValue';
import { convertLegacyOperators } from './utils';
import { convertLegacyOperators, tagInternalFilter } from './utils';

export const getGridStringQuickFilterFn = (value: any): GridApplyQuickFilterV7 | null => {
export const getGridStringQuickFilterFn = tagInternalFilter((value: any): GridApplyQuickFilterV7 | null => {
if (!value) {
return null;
}
Expand All @@ -15,7 +15,7 @@ export const getGridStringQuickFilterFn = (value: any): GridApplyQuickFilterV7 |
const columnValue = apiRef.current.getRowFormattedValue(row, column);
return columnValue != null ? filterRegex.test(columnValue.toString()) : false;
};
};
});

export const getGridStringOperators = (
disableTrim: boolean = false,
Expand Down
4 changes: 2 additions & 2 deletions packages/grid/x-data-grid/src/colDef/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ export function convertLegacyOperators(
export function convertQuickFilterV7ToLegacy(
fn: GetApplyQuickFilterFnV7,
): GetApplyQuickFilterFnLegacy<any, any, any> {
return (filterItem, column, apiRef) => {
return tagInternalFilter((filterItem, column, apiRef) => {
const filterFn = fn(filterItem, column, apiRef);
if (!filterFn) {
return filterFn;
}
return (cellParams): boolean => {
return filterFn(cellParams.value, cellParams.row, column, apiRef);
};
};
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,10 @@ export const buildAggregatedQuickFilterApplier = (
const getApplyQuickFilterFn = column?.getApplyQuickFilterFn;
const getApplyQuickFilterFnV7 = column?.getApplyQuickFilterFnV7;

if (getApplyQuickFilterFnV7) {
const hasUserFunctionLegacy = !isInternalFilter(getApplyQuickFilterFn);
const hasUserFunctionV7 = !isInternalFilter(getApplyQuickFilterFnV7);

if (getApplyQuickFilterFnV7 && !(hasUserFunctionLegacy && !hasUserFunctionV7)) {
appliersPerField.push({
column,
appliers: quickFilterValues.map((value) => ({
Expand Down