Forum /
Sencha Touch 2.x Forums /
Sencha Touch 2.x: Discussion /
Setting selectfield displayitem text and value from local storage
Setting selectfield displayitem text and value from local storage
How to set Select field selected value from local storage? the select field is already populated from a store and last selected value is in local storage, i need to retail it when i reopens the app.
Sencha - Senior Forum Manager
How are you saving the value?
thanks for the replay , i have fixed this
Hey, I am new to the sencha touch...
I have created a controller and a 2 views...
I have saved the data from 1st view into the controller..
Now I want to access that data into second view...
Please Help....
How you are saving the data? Local store?
No I am storring it in controller using the fireEvent of button.... i.e when button is clicked the event is generated and object is created and the object is redirected to the controller... I have printed it on console.. but not able to take the data to another view.. Plz help....
Thanks
we can do this in different ways, please share the code you are trying
Settings.js (My Controller)
Ext.define('MobileClient_HTML5.controller.Settings',{
extend: 'Ext.app.Controller',
requires:['MobileClient_HTML5.view.Setting'],
config:{
refs:{
SettingsView: 'settingform',
//mainmenuView: 'mainmenuview'
},
control:{
SettingsView:{ saveCommand: 'onSaveCommand'},
//changeSettingCommand: 'onChangeSettingCommand'},
//activate: 'onActivate'
}
},
onSaveCommand: function (view, servername,port, contextRoot)
{
console.log('servername: '+servername+'\n'+'port: '+ port+'\n'+'contextRoot: '+ contextRoot);
}
});
View/setting.js (Where I accept the data)
Ext.define('MobileClient_HTML5.view.Setting', {
extend: 'Ext.form.Panel',
alias: "widget.settingform",
fullscreen: 'fit',
requires: ['Ext.TitleBar', 'Ext.form.FieldSet', , 'Ext.Img', 'Ext.util.DelayedTask','Ext.Label'],
config: {
title: 'Settings',
iconCls: 'settings',
items: [
{
xtype: 'titlebar',
title: 'Server Settings',
docked: 'top'
},
{
xtype: 'fieldset',
//title: 'Server Settings',
items: [
{
xtype: 'textfield',
label:'Server Name:',
placeHolder: 'Enter the name of Server',
itemId: 'serverNameTextField',
name: 'serverNameTextField',
required: true
},
{
xtype: 'textfield',
label:'Port Number:',
placeHolder: 'Enter the Port Number',
itemId: 'portTextField',
name: 'portTextField',
required: true
},
{
xtype: 'textfield',
label:'Context Root:',
placeHolder: 'Enter the Context Root',
itemId: 'contextTextField',
name: 'contextTextField',
required: true
}
]
},
{
xtype: 'toolbar',
layout: {
pack: 'center'
}, // layout
ui: 'plain',
items:[{
xtype: 'button',
itemId: 'saveButton',
ui: 'confirm',
text: 'Save'
}
]
}
],
listeners: [{
delegate: '#saveButton',
event: 'tap',
fn: 'onSaveButtonTap'
}]
},
onSaveButtonTap: function () {
var me = this,
servernameField = me.down('#serverNameTextField'),
portField = me.down('#portTextField'),
contextField=me.down('#contextTextField'),
label = me.down('#signInFailedLabel'),
servername = servernameField.getValue(),
port = portField.getValue(),
contextRoot = contextField.getValue();
//console.log(servername);
//console.log(port);
//console.log(contextRoot);
//label.hide();
// Using a delayed task in order to give the hide animation above
// time to finish before executing the next steps.
var task = Ext.create('Ext.util.DelayedTask', function () {
//label.setHtml('');
me.fireEvent('saveCommand', me, servername, port, contextRoot);
servernameField.setValue('');
portField.setValue('');
contextField.setValue('');
});
task.delay(500);
},
showSignInFailedMessage: function (message) {
var label = this.down('#signInFailedLabel');
label.setHtml(message);
label.show();
}
});
Now I want to carry the Data (ServerName, port, context path) to another view...
this is the first view of myapp.. Can i navigate the values here?
Ext.define("MobileClient_HTML5.view.Main", {
extend: 'Ext.tab.Panel',
id:'tabpnl',
requires: ['Ext.TitleBar','Ext.field.Select','Ext.field.Search'],
config: {
tabBarPosition: 'bottom',
//text:'Mobile Cube',
styleHtmlContent: true,
xtype: 'fieldset',
items: [
{
xtype:'homeform'
},
{
// xtype:'storepanel'
xtype:'mainmenuview',
},
{
xtype:'accountform'
},
{
xtype:'orderform'
},
{
xtype:'settingform'
},
]
}
});
I don't Know how to do it..
Plz Help...
Thanks....
Sencha is used by over two million developers. Join the community, wherever you’d like that community to be
or Join Us