Sencha touch 2 Sencha Touch-如何将控制器中的值传递到视图中存储?
我使用应用商店筛选器搜索类别应用。搜索应用类别的值来自控制器。但我不知道如何将值从控制器传递到视图,以便在视图中使用应用商店筛选器。查看我的代码: 这是我的控制器:Sencha touch 2 Sencha Touch-如何将控制器中的值传递到视图中存储?,sencha-touch-2,Sencha Touch 2,我使用应用商店筛选器搜索类别应用。搜索应用类别的值来自控制器。但我不知道如何将值从控制器传递到视图,以便在视图中使用应用商店筛选器。查看我的代码: 这是我的控制器: Ext.define('Catalog.controller.Main', { extend: 'Ext.app.Controller', config: { refs: { homepanel: 'homepanel', but: 'homepane
Ext.define('Catalog.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
homepanel: 'homepanel',
but: 'homepanel #category',
categoryButton: 'button[action=Categories]',
list:'list',
homepanellist: 'homepanel #Applist',
navigationlist: 'navigation #Catlist',
navigation: 'navigation'
},
control: {
homepanellist:{
itemtap: 'showApp'
},
categoryButton:{
tap: 'showCat'
},
homepanel: {
back: 'backButtonHandler'
},
navigationlist:{
itemtap: 'showCatQuery'
},
navigation:{
back: 'backButtonNav'
}
}
},
//called when the Application is launched, remove if not needed
showApp: function(list,index,element,record) {
Ext.getCmp('category').hide();
// this.getBut().setHidden(true);
var Catname = Ext.get('catname').dom.innerHTML;
var butDown = '';
var gal = record.get('gallery');
var items2 = [];
if(gal.length > 0){
for(var i = 0; i < gal.length;i++){
items2.push({
html:'<center><img style="margin-top:10px;" src="http://127.0.0.1:3000/system/gallery_apps/imgs/000/000/'+gal[i].id+'/original/'+gal[i].img_file_name+'" width="200" height="300"></center>'
})
}
}
// Check OS Mobile
if(Ext.os.name == "iOS"){
butDown = "<div style='float:right;position: relative;top: -20px;'><a href='"+record.get('url_ios')+"'><img src='touch/resources/images/d_ios.png' style='width: 100px;float: right;margin-top: -15px;'></a></div>";
}else{
butDown = "<div style='float:right;position: relative;top: -20px;'><a href='"+record.get('url_android')+"'><img src='touch/resources/images/d_and.png' style='width: 100px;float: right;margin-top: -15px;'></a></div>";
}
// Check OS Mobile
this.getHomepanel().push({
xtype: 'panel',
title: 'info',
scrollable: true,
styleHtmlContent: true,
layout: {
type: 'vbox'
},
items: [
{
xtype: 'panel',
style: 'margin-left: -1.2em;margin-right: -1.2em;margin-top: -1.2em;',
height:100,
html: '<div style="width: 100%;height: 100px;padding: 1.2em;border-bottom:2px ridge #C5C7BC;">'+
'<div style="float:left;width:85px;">'+
'<img src="http://127.0.0.1:3000/system/appinfos/appicons/000/000/'+record.get('id')+'/original/'+record.get('appicon_file_name')+'" width="75" heigh="75"></img>'+
'</div>'+
'<div style="word-wrap: break-word;"><b><p style="font-size:15px;margin:0;">'+record.get('name')+'</p></b><p>'+Catname+'</p></div>'+
butDown+
'</div>'+
'<div style="clear:both;"></div>'
},
{
// xtype:'datascreen',
// data:record.data
xtype:'carousel',
direction: 'horizontal',
height:325,
style: 'margin-left: -1.2em;margin-right: -1.2em;background-color:#C0C0C0;box-shadow:inset 3px 3px 49px #fafafa;border-bottom:2px ridge #C5C7BC;',
listeners:
{
'afterrender': function(carousel) {
carousel.pageTurner = new Ext.util.DelayedTask(function() {
if (this.getActiveIndex() == this.items.length - 1) {
this.setActiveItem(0, 'slide');
}
else {
this.next();
}
this.pageTurner.delay(6000);
}, carousel);
carousel.pageTurner.delay(6000);
}
},
items: items2
},
{
xtype: 'panel',
style: 'margin-left: -1.2em;margin-right: -1.2em;',
html:
'<div style="width: 100%;padding: 1.2em;border-bottom:2px ridge #C5C7BC;">'+
'<h1 style="font-size:16px;font-weight:bold;color:black;">Description</h1>'+
'<div id="deS">'+
record.get('description')+
'</div>'+
'</div>'
}
]
});
},
backButtonHandler: function(button){
Ext.getCmp('category').show();
},
backButtonNav: function(button){
Ext.getCmp('category').hide();
},
showCat: function(btn){
Ext.getCmp('category').hide();
this.getHomepanel().push(
{
xtype: 'panel',
title: 'Categories',
scrollable: true,
styleHtmlContent: true,
layout: {
type: 'fit'
},
items: [
{
xtype: 'navigation'
}
]
}
);
// this.but().setHidden(true);
},
showCatQuery: function(list,index,element,record){
// var sto = Ext.getStore('myStore');
// sto.clearFilter();
// sto.filter('id', record.get('id'));
// console.log(record.get('id'));
var catid = record.get('id'); << This Value for send to view for store filter
this.getNavigation().push({
xtype: 'panel',
title: 'A',
scrollable: true,
styleHtmlContent: true,
layout: {
type: 'fit'
},
items: [
{
xtype: 'showSearchCategory',
}
]
});
}
});
Ext.define('Catalog.controller.Main'{
扩展:“Ext.app.Controller”,
配置:{
参考文献:{
homepanel:“homepanel”,
但是:“homepanel#category”,
categoryButton:“按钮[action=Categories]”,
列表:'list',
homepanel成员:“homepanel#Applist”,
导航列表:“导航#Catlist”,
导航:“导航”
},
控制:{
家庭小组成员:{
itemtap:“showApp”
},
类别按钮:{
点击:“showCat”
},
主页面板:{
back:“backButtonHandler”
},
导航列表:{
itemtap:“showCatQuery”
},
导航:{
back:“backButtonNav”
}
}
},
//启动应用程序时调用,如果不需要,请删除
showApp:函数(列表、索引、元素、记录){
Ext.getCmp('category').hide();
//this.getBut().setHidden(true);
var Catname=Ext.get('Catname').dom.innerHTML;
var Button=“”;
var gal=record.get('gallery');
var items2=[];
如果(加仑长度>0){
对于(变量i=0;i“+record.get('name')+”“+Catname+””+
布顿+
''+
''
},
{
//xtype:“数据屏幕”,
//数据:record.data
X类型:'carousel',
方向:'水平',
身高:325,
样式:“左边距:-1.2米;右边距:-1.2米;背景色:#C0C0C0C0;方框阴影:插入3px 3px 49px#fafafa;边框底部:2px脊线#C5C7BC;”,
听众:
{
“afterrender”:函数(旋转木马){
carousel.pageTurner=new Ext.util.DelayedTask(函数(){
if(this.getActiveIndex()==this.items.length-1){
此.setActiveItem(0,“幻灯片”);
}
否则{
这个。下一个();
}
本.页特纳.延迟(6000);
}(旋转木马);
传送带寻呼机延迟(6000);
}
},
项目:项目2
},
{
xtype:'面板',
样式:“左边距:-1.2米;右边距:-1.2米;”,
html:
''+
“说明”+
''+
record.get('description')+
''+
''
}
]
});
},
backButtonHandler:函数(按钮){
Ext.getCmp('category').show();
},
backButtonNav:功能(按钮){
Ext.getCmp('category').hide();
},
showCat:功能(btn){
Ext.getCmp('category').hide();
这是.getHomepanel().push(
{
xtype:'面板',
标题:“类别”,
可滚动:对,
styleHtmlContent:对,
布局:{
类型:“适合”
},
项目:[
{
xtype:“导航”
}
]
}
);
//this.but().setHidden(true);
},
showCatQuery:函数(列表、索引、元素、记录){
//var sto=Ext.getStore('myStore');
//sto.clearFilter();
//sto.filter('id',record.get('id');
//console.log(record.get('id'));
var catid=record.get('id');您可以将该值作为配置属性传递,这样ST将自动创建其getter和setter:
showCatQuery: function(list,index,element,record){
var catid = record.get('id'); //This Value for send to view for store filter
this.getNavigation().push({
xtype: 'panel',
title: 'A',
scrollable: true,
styleHtmlContent: true,
catid: catid,
layout: {
type: 'fit'
},
items: [
{
xtype: 'showSearchCategory',
}
]
});
}
然后,在视图中,getter getCatId()应该可用:
initialize: function() {
this.callParent(arguments);
var sto = Ext.getStore('allapp');
sto.clearFilter();
sto.filter('categoryid', this.getCatid() );
}
希望有帮助-错误消息:未捕获类型错误:对象[Object Object]没有方法“getCatid”错误消息:未捕获类型错误:对象[Object Object]没有方法“getCatid”
initialize: function() {
this.callParent(arguments);
var sto = Ext.getStore('allapp');
sto.clearFilter();
sto.filter('categoryid', this.getCatid() );
}