PDA

View Full Version : setting up pull to refresh list



macs
27 Apr 2012, 11:38 AM
hi i can see everywhere that the pull to refresh plugin is working. unfortunately i seem to be not able to get it to work. i am using a store to populate a list. when i use a regular refresh button and execute the store load method when the button is tapped everything works fine/ i get the loading message and the list is updated. with the pull to refresh plugin, nothing is obviously executed after releasing the list. the text and graphics are rendered as they should however the updatedata event is not fired and the list is not refreshed. i also hoped i could simply bind to something like a "release" event which i can listen to and do the shop load method manually, but there is no such event. at least in the docs there is no such event/ or did i miss anything? what is it that i am doing wrong?

the store gets defined like this


Ext.define('VB1.store.MyListStore', {
extend: 'Ext.data.Store',
config: {
storeId: 'vbMyStore',
model: 'VB1.model.MyModel',
autoLoad: true,
proxy: {
type: 'jsonp',
url : 'myUrl.js?',
reader: {
type: 'json',
rootProperty: 'array.resources'
},
},
},
});

the list looks like this:


Ext.define('VB1.view.MyListView', {
extend: 'Ext.dataview.List',
alias: 'widget.mylistview',
requires: [
'Ext.dataview.List','Ext.plugin.PullRefresh',
],
config: {
plugins: [
{
xclass: 'Ext.plugin.PullRefresh',
pullRefreshText: 'Pull down to Refresh!'
}
],
scrollable: 'vertical',
loadingText: "loading...",
emptyText: '</pre><div>No notes found.</div><pre>',
itemTpl: '</pre><div>{title}</div><pre>',
listeners: {
updatedata: function (me, newData, eOpts ) {
console.log(newData)
}
},
},
});

i finally instantiate the view like so:


var myListView = {
xtype: 'mylistview',
store: 'vbMyStore',
}

Ext.Viewport.add([myListView]);

mitchellsimoens
30 Apr 2012, 6:54 AM
Are you using idProperty config or specifying data in the id field?

macs
1 May 2012, 4:11 AM
sorry mitchell i am not sure whether i understand the question correctly. but probably you are tapping right into my problem since i think i do none of that. see code above. i simply link the store to the view and was hoping that the pullrefresh executes a store load and refreshes the data in the list. where should i use the idProperty config or specifying data in the id field?

mitchellsimoens
1 May 2012, 4:59 AM
The pullrefresh plugin doesn't do a store.load() at all. In your response, do you have the id property set in your record data?

macs
2 May 2012, 4:22 AM
actually i thought i did not set the id property in the model. i use a field named id in my model though/ the idProperty is set to id by default, which means i do have the idProperty configured/ based on your hint i found here http://www.sencha.com/forum/showthread.php?190197-Duplicated-Record-Appears-when-Pulling-to-Refresh that When refreshing with the same data set, unique identifiers prevent duplicates.

does that mean that if the data already exists it does not refresh and hence the updatedata event is not fired (as in my case)? what if the data has changed (eg the price of a product) but the id of an data item remained the same?

penguintux
5 May 2013, 9:22 PM
Is there any solution to this?