Wednesday, 15 July 2015

add text field values to localstore from field set in sencha touch 2 -



add text field values to localstore from field set in sencha touch 2 -

i new sencha touch , error in below code tab alter function error:uncaught typeerror: object [object object] has no method '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();

below code feild set code

{ 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 code model

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' } ] } });

below code store

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' } } });

my aim text feid values stored in browser localstore. please help me buddy. in advance.

you should first set id each field, example

{ xtype: 'textfield', label: 'name', name: 'name', maxlength: 31, placeholder: 'given-name family-name', itemid: 'tfname' },

then can value of field after event in function

var namefield = this.down('#tfname'); var namevalue = namefield.getvalue();

...

and can add together value store

var store = ext.getstore('userlocalsettings'); store.add({name: namevalue}); store.sync();

hope help.

sencha-touch touch sencha-touch-2 local-storage

No comments:

Post a Comment