PDA

View Full Version : mvc communiction between controller view and store



thele
21 Jul 2011, 1:40 PM
hello there!

im new to sencha touch, and i had a problem to access a controller option inside a store.
i want add a parameter to the url of a proxy. how i can access the variable inside the store?

here is the controller:

Ext.regController("market", {

init: function(){
this.indexView = this.render({
xtype: 'MarketIndex'
});
this.devicesView = this.render({
xtype: 'DevicesView'
})
},

index: function(options){
app.views.viewport.setActiveItem(this.indexView, options.animation);
},

devices: function(options){
console.log(options.uid); // the id wich i want to access inside the store
app.views.viewport.setActiveItem(this.devicesView,options.animation);
}

});

at first comes a list with companies. on click on a company comes a second list, with products from the company. but for that i need to add the company id, the the url of the proxy of the store. an this in dont get it ;-(

here is the view


Ext.reg("DevicesView", Ext.extend(Ext.Panel, {
layout : 'fit',
dockedItems : [ {
xtype : 'panel',
type:'fit',
pack:'center',
align:'center',

items : [ {
xtype : 'toolbar',
ui:'light',
title:'Market',
items : [ {
xtype : 'segmentedbutton',
//flex : 1,
items : [ {
text : 'Hersteller',
listeners : {
tap : function() {
Ext.dispatch({
controller : 'market',
action : 'index',
historyUrl : 'market/index',
animation : {
type : 'slide',
direction : 'up'
}
});
}
},
pressed : true,
//flex : 1
}, {
text : 'Anwendungen',

//flex : 1,

// handler: tapHandler
}, {
text : 'Suche',
//flex : 1,
//align : 'right',
/// handler: tapHandler
} ]
} ]
} ]
}, {
xtype : 'toolbar',
ui : 'confirm-round',
dock : 'bottom',
flex:1,
items : [ {
iconMask : true,
text : 'Market',
pressed : true,
//ui:'action',
flex:1,
align : 'center',

iconCls : 'home'
}, {
iconMask : true,
flex:1,
text : 'News',
}, {
iconMask : true,
flex:1,
text : 'Dates',
}

]
}

],

items : [ {
xtype : 'list',
store : 'Devices', //in this store i want access the record.data.id inside the url of the proxy
itemTpl : '{name} - {count}',
onItemDisclosure : function(record) {
Ext.dispatch({
controller : 'market',
action : 'devices',
historyUrl : 'market/devices/' + record.data.id,
record : record
});
alert(this.test);

}
} ]
}));

and here is the store

Ext.regStore('Devices', {
model : 'Devices',
id:'Devices',
sorters: 'title',
proxy: {
type: 'ajax',
url : 'http://localhost/stage/index.php?id=310&article[action]=browse&filter=' + XXX, ///how can i access here to a variable from the 'DevicesView' ???
reader: {
type: 'json',
root: 'devices'
}
},
});


i would really happy for every suggestions!

greetings,
frank.