PDA

View Full Version : [CLOSED] datachanged event has wrong parameters or isn't always fired



jep
10 Feb 2012, 4:05 PM
Sencha Touch version tested:

1.1.1


Platform tested against:

Chrome 16


Description:

Describe the problem in greater detail here, summarizing the behavior.


Test Case:



Ext.regModel('TestModel', {
fields:[{name: 'f'}],
sortField:'f'
});

var myStore = new Ext.data.Store({
model: 'TestModel',
proxy:{
type:'localstorage',
id:'TestStorage'
},
listeners:{
datachanged:function () {
console.log(' +-- data changed', arguments);
}
}
});

localStorage.clear();

console.log('adding');
myStore.add([{f:1}, {f:2}, {f:3}, {f:4}]);

console.log('loadData');
myStore.loadData([{f:1}, {f:2}, {f:3}, {f:4}]);

console.log('removing');
myStore.removeAt(0);

console.log('sorting');
myStore.sort();

console.log('filtering');
myStore.filter();

console.log('syncing');
myStore.sync();

console.log('loading');
myStore.load();

console.log('updating');
myStore.getAt(0).set('f', 42);

console.log('removeAll');
myStore.removeAll();


See this URL : http://


Steps to reproduce the problem:

Run the app


The result that was expected:

According to the docs, datachanged "fires whenever the records in the Store have changed in some way - this could include adding or removing records, or updating the data in existing records
Listeners will be called with the following arguments:

this : Ext.data.Store
The data store"


The result that occurs instead:


adding
+-- data changed [Ext.data.Store.Ext.extend.constructor, Object]
loadData
+-- data changed [Ext.data.Store.Ext.extend.constructor, Array[4], Object]
removing
+-- data changed [Ext.data.Store.Ext.extend.constructor, Object]
sorting
+-- data changed [Ext.data.Store.Ext.extend.constructor, Object]
filtering
+-- data changed [Ext.data.Store.Ext.extend.constructor, Object]
syncing
+-- data changed [Object]
loading
+-- data changed [Ext.data.Store.Ext.extend.constructor, Array[3], Object]
updating
removeAll



For all events fired, the last argument is the listener. I'm going to pretend like that doesn't exist below.
For add(), removeAt(), sort(), and filter(), the expected first parameter of the store is received.
For sync(), the store parameter is missing.
For update (via record.set()), no event is fired. This seems to conflict with what the help text claimed.
For removeAll() (a method that isn't documented in 1.1.1 but isn't marked private - seems like a documentation oversight as it is documented in 2.0 beta), no event is fired.
For loadData() and load(), an extra parameter showing the records loaded is included. Kind of odd.


Part of this is a repeats a previous bug report (http://www.sencha.com/forum/showthread.php?138567-Store-datachanged-event-inconsistency&highlight=datachanged), but hopefully this one will make it into the bug system since it's formatted right. It also has a little more detail.

On a related note, I really wish datachanged had more useful parameters. However, as I notice it is missing in the documentation for 2.0, you may have just decided to remove it.

mitchellsimoens
12 Feb 2012, 8:18 AM
Thank you for the report.