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] Allow to control visibility of columns shown in ColumnsPanel
#8401
Merged
MBilalShafi
merged 5 commits into
mui:master
from
MBilalShafi:7534-columns-panel-enhancement
Apr 3, 2023
Merged
[DataGrid] Allow to control visibility of columns shown in ColumnsPanel
#8401
MBilalShafi
merged 5 commits into
mui:master
from
MBilalShafi:7534-columns-panel-enhancement
Apr 3, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MBilalShafi
added
component: data grid
This is the name of the generic UI component, not the React module!
enhancement
This is not a bug, nor a new feature
labels
Mar 27, 2023
Netlify deploy previewNetlify deploy preview: https://deploy-preview-8401--material-ui-x.netlify.app/ Updated pagesThese are the results for the performance tests:
|
cherniavskii
approved these changes
Mar 31, 2023
Comment on lines
175
to
191
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null; | ||
|
||
if (!searchValue) { | ||
return sortedColumns; | ||
return togglableColumns | ||
? sortedColumns.filter(({ field }) => togglableColumns.includes(field)) | ||
: sortedColumns; | ||
} | ||
const searchValueToCheck = searchValue.toLowerCase(); | ||
return sortedColumns.filter((column) => searchPredicate(column, searchValueToCheck)); | ||
}, [sortedColumns, searchValue, searchPredicate]); | ||
return sortedColumns.filter((column) => { | ||
if (togglableColumns) { | ||
return ( | ||
togglableColumns.includes(column.field) && searchPredicate(column, searchValueToCheck) | ||
); | ||
} | ||
return searchPredicate(column, searchValueToCheck); | ||
}); | ||
}, [sortedColumns, searchValue, searchPredicate, getTogglableColumns]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opportunity to simplify this code?
const togglableColumns = getTogglableColumns ? getTogglableColumns(sortedColumns) : null;
const togglableSortedColumns = togglableColumns
? sortedColumns.filter(({ field }) => togglableColumns.includes(field))
: sortedColumns;
if (!searchValue) {
return togglableSortedColumns;
}
const searchValueToCheck = searchValue.toLowerCase();
return togglableSortedColumns.filter((column) => searchPredicate(column, searchValueToCheck));
What do you think?
This was referenced Apr 3, 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!
enhancement
This is not a bug, nor a new feature
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #7534
Preview: https://deploy-preview-8401--material-ui-x.netlify.app/x/react-data-grid/column-visibility/#customize-the-list-of-columns-in-panel