him*_*shu 2 checkbox android sencha-touch-2
朋友你好我被困在sencha touch 2.0中的一个点.我正在我的应用程序中创建一个屏幕,我需要获取复选框值(选中或取消选中).我从sencha文档中引用这个例子,但我无法理解如何使用Ext.ComponentQuery.query('这里有什么?')[0].
编辑
这是我的代码: -
Ext.define('MyApp.view.groupList',{
extend : 'Ext.navigation.View',
requires: ['Ext.field.Search', 'Ext.TitleBar'],
alias: "widget.groupList",
itemId: "gList",
initialize: function(){
this.callParent(arguments),
var checkBox = {
xtype: 'checkboxfield',
name : 'all',
// label: 'All',
value: 'all',
lableWidth: "0",
width: 1,
padding: '0 0 15 30',
checked: false
};
var sendBtn = {
itemId: 'sendBtn',
xtype: 'button',
text: 'Send',
ui: 'action',
handler: function() {
var check = Ext.ComponentQuery.query('navigationview')[0],
values = check.getValues();
Ext.Msg.alert(null,
"Selected All: " + ((values.all) ? "yes" : "no")
);
}
};
var topToolbar = {
xtype : "toolbar",
title : "Groups",
docked : "top",
items: [
checkBox,
{xtype: 'spacer'},
// searchBtn,
sendBtn
],
};
var list = {
xtype: "grlist",
store: Ext.getStore("grStore")
};
this.add([list,topToolbar]);
},
config: {
navigationBar: {
hidden: true,
},
}
});
Run Code Online (Sandbox Code Playgroud)
我收到以下错误: -
TypeError: Result of expression 'check.getValues' [undefined] is not a function. at
file:///android_asset/www/app/view/group_list.js
Run Code Online (Sandbox Code Playgroud)
所以请让我了解Ext.ComponentQuery如何使用一些示例代码或教程.
Thanx提前.
Ext.ComponentQuery 接受3种类型的参数:
xtype,例如: Ext.ComponentQuery.query('navigationview')id,例如: Ext.ComponentQuery.query('my-nav-view-id')attributes,例如: Ext.ComponentQuery.query('navigationview[name="my nav view"]')无论param属于哪种类型,Ext.ComponentQuery.query()总是返回匹配组件的数组.在示例中,他们添加,[0]因为它确保结果数组只包含1个项目.
在您的代码中,您似乎尝试查询xtype的组件navigationview,这种组件没有getValues方法(仅适用于Ext.form.Panel派生类).因此,如果要检索值,则必须使用如下查询:
Ext.ComponentQuery.query('checkboxfield')[0]
希望能帮助到你.
| 归档时间: |
|
| 查看次数: |
6340 次 |
| 最近记录: |