angular-ui/ui-grid

restoreState triggering multiple filterChanged events

Open

#5.280 aberto em 4 de abr. de 2016

Ver no GitHub
 (5 comments) (3 reactions) (0 assignees)JavaScript (2.496 forks)batch import
help wantedseverity: performance

Métricas do repositório

Stars
 (5.395 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

When restoring a particular grid state with several filter parameters I noticed the filterChanged event triggered several times invoking the listener several times (in my case a bunch of ajax requests).

Base on the documentation (and code), the event doesn't return which filter changed so it seems useless to trigger all those events especially in the context of restoring state. Is this by design? If not, this seems like a bug to me. It would be better if it watched for changes similar to sortChanged.

I don't have a plunkr, but a simple way to reproduce would be to have multiple filters applied to a grid, save the state, restore the state. The grid.api.core.on.filterChanged should trigger several times when restoring the grid state.

Where the filterChanged event is invoked: https://github.com/angular-ui/ui-grid/blob/master/src/features/saveState/js/saveState.js#L592.

Where the sortChanged event is invoked: https://github.com/angular-ui/ui-grid/blob/master/src/features/saveState/js/saveState.js#L610

Guia do colaborador