-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
HideColumnByIds performance #1728
Comments
hmm I'm never using this function for more than 1 or 2 columns and never with a dozen of columns and so I've never noticed the perf impact. slickgrid-universal/packages/common/src/services/grid.service.ts Lines 219 to 227 in 4c4fb79
Ahhh, it looks like I've already thought of adding the option in the plural function but I forgot to also add it to the singular function (it should be disabled in the singular when looping, same as what I've done for slickgrid-universal/packages/common/src/services/grid.service.ts Lines 246 to 249 in 4c4fb79
Technically speaking SlickGrid always worked with the concept of any columns missing when calling the |
Actually I also see that
This option should default to slickgrid-universal/packages/common/src/services/grid.service.ts Lines 242 to 253 in 4c4fb79
@ttzn Would you like to contribute a fix? |
Thanks for looking into this.
Not just probably, but positively. This can easily be seen in any browser profiler, that's how I found the issue in the first place.
I will open a PR with your suggested fix shortly. What about adding a |
I'm not sure it's really needed since you can simply call |
Just to be clear, I wouldn't mind if you add a showColumnsById(columnIds: Column[]) {
this._grid.setColumns(columnIds);
this.sharedService.visibleColumns = columnIds; // keep ref for ColumnPicker/GridMenu
} though you'll need to add unit tests for this because the entire project has unit tests 😉 and to avoid duplicating code, I guess you could refactor the code to call this new function have less duplicated code and automatically covers test coverage (I would however still prefer a single unit test for it). The lines below have to be refactored anyway with the other suggestion with a new option, so using this new show function inside the new if condition might be a good refactoring to do. slickgrid-universal/packages/common/src/services/grid.service.ts Lines 204 to 207 in 4c4fb79
|
I see you went ahead with the fix yourself, thanks for taking care of this! When can we expect a release? |
Clear and concise description of the problem
Hello,
I've been using
slickgrid-react
to power a live-updating grid containing thousands of rows, with quite some success. This grid has external controls to toggle visibility of groups of columns, some of which contain more than a dozen columns with various stylings. The problem is that hiding 10 columns at a time takes several seconds during which the UI is frozen, and this is due to the fact thathideColumnByIds
callshideColumnById
for each provided column, causing unneeded re-renders.This problem is compounded by the fact that there doesn't seem to be a straightforward way of showing back hidden columns programmatically (unless I missed something in the documentation), so I'm currently resorting to resetting the whole grid then hiding fields which are still toggled out; needless to say it takes way longer than it needs to.
Suggested solution
hideColumnByIds
should be reimplemented to only callsetColumns
after building the final array of visible columns; I'm willing to open a PR for this. A solution to my secondary problem would be to add ashowColumnsById
method to theGridService
, if you're OK with both changes in a single PR (otherwise I can open a separate issue).Alternative
I'm not sure if
setColumns
or changingsharedService.visibleColumns
trigger any logic or events across the framework that someone might rely on; if you want to be very conservative this new behaviour could be made opt-in through an additional configuration property.Additional context
Thanks for all the hard work!
Validations
The text was updated successfully, but these errors were encountered: