PDA

View Full Version : Need help auto refreshing treestore



Ormen82
27 Mar 2012, 11:32 PM
Hi

Im currently working on on a school project creating a task-planner with sencha touch 2.

I need a way to auto refresh the list of tasks every minute or so. Is there a way to refresh the treestore dynamically without reloading the entire page? Im pretty new with Sencha, so some detailed help would be appreciated.

Im just getting started, but this is my code so far:






Ext.require([
'Ext.data.TreeStore',
'Ext.NestedList',
'Ext.TitleBar',
'Ext.data.JsonReader'
]);




Ext.application({
name: 'Sencha',


launch: function() {

Ext.regModel('oppgaver', {
idProperty: 'text',


});


Ext.create("Ext.tab.Panel", {
fullscreen: true,
tabBarPosition: 'bottom',

items: [
{
xtype: 'nestedlist',
title: 'Oppgaver',
iconCls: 'star',



store: {
type: 'tree',
model: 'oppgaver',
id: 'store',
autoLoad: true,
defaultRootProperty: 'items',




proxy: {
remoteSort: true,
type: 'ajax',
url: 'json.php',
reader: {
type: 'json',
root: 'items',
totalProperty: 'count'
}

}

},






listeners: {
leafitemtap: function(nestedList, list, index, target, record) {
if(record.get('text') == "Oppgave utført"){


Ext.Msg.alert(

"", // the message of the alert
"Du har utført oppgaven"




);


}
else if(record.get('text') == "Utsett en time") {
Ext.Msg.alert(
"", // the message of the alert
"Du har valgt å utsette oppgaven en time"
);
}

else if(record.get('text') == "Utsett til neste dag") {
Ext.Msg.alert(
"", // the message of the alert
"Du har valgt å utsette oppgaven til neste dag"
);
}


}



}
},


{
xtype: 'formpanel',
title: 'Rolle',
iconCls: 'user',
url: 'roller.php',
layout: 'vbox',
items: [
{
xtype: 'textfield',
label: 'Rolle',
name: 'rolle'
},
{
xtype: 'textfield',
label: 'Butikk',
name: 'butikk'
},
{
xtype: 'button',
text: 'Velg',
ui: 'valg',
}

]
}




]
});
}
});

mitchellsimoens
28 Mar 2012, 5:59 AM
Reload the store, are you going to want to go back to the root also?

Ormen82
28 Mar 2012, 11:13 PM
I don't think i need to go back to root. I need the list to update, so it shows the newest entries in my mysql database. The database is updated from an external application.