有人可以告诉我如何通过sencha touch将数据从控制器传递到数据存储。
查看代码
var select = new Ext.form.Select({
id:'selectCity',
store: parking.stores.city,
displayField: 'Name',
valueField: 'Name',
placeHolder: 'Choose City',
cls:'select'
});
var citySearchButton = new Ext.Button({
cls: 'citySearch',
text: 'Search',
handler: function () {
Ext.dispatch({
controller: parking.controllers.controller,
action: 'showMapBasedOnCity',
id: Ext.getCmp('selectCity').getValue()
});
}
});
从我的视图我能够将值传递给控制器。
showMapBasedOnCity: function (options) {
var city = options.id;
//var data = parking.stores.parkingFacilityByCity.setId(city);
// parking.views.map.addMap(city);
parking.views.viewport.setActiveItem(
parking.views.map, options.animation
);
},
问题是如何将值从这里传递到数据存储:我需要来自controller(城市值)的参数传递给我的jsonp查询以获得所需的结果。)
parking.stores.parkingFacilityByCity = new Ext.data.Store({
model: 'PF',
proxy: Ext.util.JSONP.request({
url: 'http://parking.511.org/index/M_GetParkingFacilityByCity',
callbackKey: 'callback',
parmas: { city: },
scope: this,
callback: function (data) {
var list = data.Root;
parking.stores.parkingFacilityByCity.loadData(data.Root);
}
})
});
非常感谢任何帮助。
谢谢, Pawan
答案 0 :(得分:1)
在我的表单按钮上单击我从中获取值并将其传递给调度方法。在调度方法中,我调用控制器。
var select = new Ext.form.Select({
id:'selectCity',
store: parking.stores.city,
displayField: 'Name',
valueField: 'Name',
placeHolder: 'Choose City',
cls:'select'
});
var citySearchButton = new Ext.Button({
cls: 'citySearch',
text: 'Search',
handler: function () {
Ext.dispatch({
controller: parking.controllers.controller,
action: 'showMapBasedOnCity',
id: Ext.getCmp('selectCity').getValue()
});
}
});
在控制器中,我按城市调用方法获取停车设施,将新数据输入商店。
showMapBasedOnCity: function (options) {
var city = options.id;
getParkingFacilityByCity(city);
// parking.views.map.addMap();
parking.views.viewport.setActiveItem(
parking.views.map, options.animation
);
Data.js文件
parking.stores.parkingFacilityByCity = new Ext.data.Store({
model: 'PF',
autoload: true
});
var getParkingFacilityByCity = function (cityName) {
Ext.util.JSONP.request({
url: 'http://parking.511.org/index/M_GetParkingFacilityByCity',
callbackKey: 'callback',
params: { city: cityName },
callback: function (data) {
parking.stores.parkingFacilityByCity.loadData(data.Root);
}
});
};
希望这对某人有所帮助。也可能有其他方法。但这对我来说非常有用。