Sencha touch 从sencha touch 2中的字段集向localstore添加文本字段值
我是新的sencha触摸,我得到了一个错误,在下面的代码是标签更改功能Sencha touch 从sencha touch 2中的字段集向localstore添加文本字段值,sencha-touch,touch,sencha-touch-2,local-storage,Sencha Touch,Touch,Sencha Touch 2,Local Storage,我是新的sencha触摸,我得到了一个错误,在下面的代码是标签更改功能 错误:未捕获类型错误:对象[Object Object]没有方法“getValues” var uswrfeild = Ext.getCmp('User_details'); //var fieldset = Ext.create('FieldSet_PersonalSettings');
错误
:未捕获类型错误:对象[Object Object]没有方法“getValues”
var uswrfeild = Ext.getCmp('User_details');
//var fieldset = Ext.create('FieldSet_PersonalSettings');
//var fieldset= this.tab;
var values = uswrfeild.getValues();
cart = Ext.create('Items');
//alert(values);
//cart.add({field1:'value1',field2:'value2'});
cart.add(values);
cart.sync();
下面的代码是feild集合代码
{
xtype: 'container',
title: 'User',
id: 'User_details',
itemId: 'mycontainer3',
scrollable: 'vertical',
items: [
{
xtype: 'fieldset',
id: 'FieldSet_PersonalSettings',
itemId: 'myfieldset12',
margin: '2%',
title: 'User',
items: [
{
xtype: 'textfield',
label: 'Name',
name: 'name',
maxLength: 31,
placeHolder: 'given-name family-name'
},
{
xtype: 'emailfield',
label: 'Email',
name: 'email',
required: true,
maxLength: 63,
placeHolder: 'name@example.com'
},
{
xtype: 'textfield',
label: 'Street',
name: 'street',
required: true,
placeHolder: 'streetname'
},
{
xtype: 'textfield',
label: 'House Number',
required: true,
placeHolder: '123'
},
{
xtype: 'textfield',
label: 'Zipcode',
required: true,
autoCapitalize: true,
maxLength: 10,
placeHolder: '1234AA'
},
{
xtype: 'textfield',
label: 'Country',
required: true,
placeHolder: 'NL'
}
]
},
{
xtype: 'fieldset',
margin: '2%',
title: 'Sharing information',
items: [
{
xtype: 'checkboxfield',
label: 'Receive email',
labelWidth: '75%',
checked: true
},
{
xtype: 'checkboxfield',
height: 49,
label: 'Upload statistics (anonymously)',
labelWidth: '75%',
checked: true
}
]
}
belo代码是一个模型
Ext.define('iFP.model.item', {
extend: 'Ext.data.Model',
config: {
fields: [
{
name: 'name',
type: 'string'
},
{
name: 'email',
type: 'string'
},
{
name: 'street',
type: 'string'
},
{
name: 'hno',
type: 'auto'
},
{
name: 'zipcode',
type: 'int'
},
{
name: 'country',
type: 'string'
}
]
}
});
下面的代码是存储
Ext.define('iFP.store.userlocalsettings', {
extend: 'Ext.data.Store',
requires: [
'iFP.model.item'
],
config: {
autoSync: false,
model: 'iFP.model.item',
storeId: 'usersettingslocalstore',
proxy: {
type: 'localstorage'
}
}
});
我的目标是将文本feid值存储在浏览器localstore中。
请帮帮我,伙计。
提前感谢。您应该首先为每个字段设置id,例如
{
xtype: 'textfield',
label: 'Name',
name: 'name',
maxLength: 31,
placeHolder: 'given-name family-name',
itemId: 'tfName'
},
然后,您可以在函数中的某个事件之后获取字段的值
var namefield = this.down('#tfName');
var namevalue = namefield.getValue();
然后您可以将该值添加到存储
var store = Ext.getStore('userlocalsettings');
store.add({name: namevalue});
store.sync();
希望这会有所帮助。您应该为表单设置ID
config: {
itemId: 'form1'
}
然后在控制器中添加对该ID的引用
refs: {
myPanel: '#form1'
}
我看不到你的按钮侦听器。假设侦听器的名称为“onTapSave”,那么您应该试试这个
onTapSave: function(component,button, options){
var uswrfeild = this.getMyPanel();
var values = uswrfeild.getValues();
}
哪个错误?你能贴控制台吗?您正在使用哪个ST版本?