PDA

View Full Version : [OPEN] [CLOSED-623] Ext.data.Store 'clear' listener and removeAll



dave.culver
22 Feb 2010, 11:34 PM
Ext 3.1.0 added a 'clear' listener for stores with a writer. It also introduce a parameter (silent) to the Store.removeAll function, with a default value of false.

In previous releases calling removeAll simply cleared the local store.

Calling removeAll with the current release clears the local cache and deletes the back-end records.

In order to maintain backwards compatibility, I believe the default value for the removeAll silent parameter should be changed to true. This is a far less dangerous default!

evant
23 Feb 2010, 12:11 AM
I can see 2 sides to this. As you say, it is a less dangerous default and it is different from the previous behaviour.

However, it's fairly clearly written in the docs what the parameter does (though it could be more explicit). Also, if I am using a store with a writer, it would be logical for the behaviour to call the destroy event on server methods.

I'm open for some discussion on this, but since the behaviour has already been established in 3.1 I would prefer to keep it as is.

dave.culver
23 Feb 2010, 1:14 AM
Evan, thanks for getting back so promptly.

I agree that the 3.1 docs clearly cover the parameter. However there was no such parameter in 3.0, so all 3.0 users are likely to have their databases trashed when they upgrade to 3.1, unless they are aware of this change and update their sources.

jtruffot
25 Feb 2010, 6:48 AM
This new parameter to the Store.removeAll function involves a very strange bug in my app. This bug was so difficult to reproduce that I spent a week to solve it :(( .

The docs ("Set true to not fire clear event.") is not clear for me. I think the source comment "prevents write-actions when we just want to clear a store." is much better.

Moreover this new version of the removeAll function with silent set to true don't refresh the grid view (it listen the clear event to refresh).

May be we need 2 methods and/or 2 events: one to clear the local cache and an other to delete the back-end records?

dave.culver
25 Feb 2010, 7:08 AM
To me, the best solution is to check if the silent parameter is defined. If it is defined, then the app is 3.1 aware. If it is not defined, then the app is not 3.1 aware, and the default should be true (i.e. silent). It's never quite that simple though, because the event was always fired in 3.0, it's just that there were no listeners...

However, even if someone attached their own listener in 3.0 I think that the above approach is still the safest. In this scenario, when they migrate to 3.1, they may be blissfully unaware that they now have two listeners!

evant
15 Jul 2010, 5:33 AM
The behaviour will be reviewed in Ext 4, but for now we'll leave it as it is. Marking this issue as closed.