PDA

View Full Version : To get the values in textfield from store.



patel1990
10 Oct 2012, 6:03 AM
//View


Ext.define('AM.view.editaccountpanel',{
extend:'Ext.form.Panel',
alias:'widget.editaccountpanel',
id:'editaccountpanel',
bodyStyle:'border-top:none;border-left:none;border-right:none;border-bottom:none',
store:'appcontrol',
items:[
{
xtype:'textfield',
width:300,
fieldLabel:'Username',
name:'name'
},
{
xtype:'textfield',
inputType:'Password',
width:300,
fieldLabel:'password',
name:'id'
},
{
xtype:'textfield',
width:300,
fieldLabel:'Email-id'
},
{
margin:'20 0 0 80',
xtype:'button',
text:'save'
},
{
margin:'20 0 0 40',
xtype:'button',
text:'cancel',
id:'formcancel'
}
],
initComponent:function(){
//var me = this;

/*me.on('afterrender', function(){
debugger;
alert(me);
});*/


this.callParent();

}

});


//Store

Ext.define('AM.store.appcontrol', {
extend: 'Ext.data.Store',
requires: 'AM.model.appcontrol',
model: 'AM.model.appcontrol',
//fields: ['id', 'name'],
autoload: true,
// Overriding the model's default proxy
proxy: {
type: 'ajax',
url: 'data/appcontrol.json',
reader: {
type: 'json',
root: 'results'
}
}/*,

listeners: {
load: function() {
var form = Ext.getCmp('form');
form.loadRecord(store.data.first());
}
}*/



});

//Model

Ext.define('AM.model.appcontrol', {
extend: 'Ext.data.Model',
fields: ['id', 'name'],

proxy: {
type: 'ajax',
url: 'data/appcontrol.json',
reader: {
type: 'json',
root: 'results'
}
}
});


//User

Ext.define('AM.controller.user', {
extend: 'Ext.app.Controller',

views: [
'viewport',
'Chrome',
'welcome',
'accountpanel',
'logpanel',
'otrspanel',
'cancel',
'editaccountpanel'
],

stores:['appcontrol'],

refs:[
{ref:'chrome',selector:'appChrome'},
{ref:'chrome1',selector:'wel-come'},
{ref:'chrome2',selector:'cancel'},
{ref:'chrome3',selector:'accountpanel'},
{ref:'chrome4',selector:'logpanel'},
{ref:'chrome5',selector:'otrspanel'}
],

init: function() {
this.control({

'userlist #button1': {
'click' : function()
{
var flag;
var v1=Ext.getCmp('text1').getValue();
var v2=Ext.getCmp('text2').getValue();
if(v1=='k@k.com' && v2=='admin')
{
var page = this.getChrome().queryById('wel-come');
if(page == null || page.length == 0){
page=Ext.create('AM.view.welcome',
{
itemId: 'wel-come'
});
}
this.getChrome().getLayout().setActiveItem(page);
}
else
{
if(v1!='k@k.com' && v2!='admin')
{
alert('you entered wrong pwd and username');
}
else if (v1=='k@k.com')
{
if(v2!='admin')
{
//Ext.getCmp('text2').setToolIip('u enter wrong pwd');
alert('You enter the wrong pwd');
}
}
else
{

alert('you entered wrong username');
}
}
}
},

'userlist #account':{
'click':function(c){
debugger;
var page = this.getChrome().queryById('cancel');

if(page == null || page.length == 0){
page=Ext.create('AM.view.cancel',{
itemId: 'cancel'
});
}
this.getChrome().getLayout().setActiveItem(page);
}
},

'wel-come #home': {
'click' : function(){
//debugger;
this.getChrome().getLayout().setActiveItem(0);
Ext.getCmp('text1').setValue("");
Ext.getCmp('text2').setValue("");
}
},



'wel-come #treeh':{
'select':function(s,r,index,e){

if(r.get('id')=='pc1')
{
debugger;
var treeCont = Ext.getCmp('tree-container');
var page = treeCont.queryById('accountpanel');
if(page == null || page.length==0)
{
page=Ext.create('AM.view.accountpanel',
{
itemId:'accountpanel'
})
}
treeCont.getLayout().setActiveItem(page);
}
if(r.get('id')=='pc2')
{
debugger;
var treeCont=Ext.getCmp('tree-container');
var page=treeCont.queryById('otrspanel');
if(page == null || page.length == 0)
{
page=Ext.create('AM.view.otrspanel',
{
itemId:'otrspanel'
})
}
treeCont.getLayout().setActiveItem(page);
}
if(r.get('id')=='pc3')
{
var treeCont=Ext.getCmp('tree-container');
var page=treeCont.queryById('logpanel');
if(page==null || page.length==0)
{
page=Ext.create('AM.view.logpanel',
{
itemId:'logpanel'
})
}
treeCont.getLayout().setActiveItem(page);
}
}
},


'accountpanel #edit':{
'click':function(d){
// debugger;
Ext.getCmp('main').setHeight(250);
var accont=Ext.getCmp('form-container');
var page=accont.queryById('editaccountpanel');
if(page==null || page.length==0)
{
page=Ext.create('AM.view.editaccountpanel',
{
itemId:'editaccountpanel',
})
}
accont.getLayout().setActiveItem(page);
}

},

/*'editaccountpanel':{
'afterrender' : function(){
debugger;
var form = arguments[0];
var storeObj = this.getStore(form.store);
storeObj.load();
//form.loadRecord();

}
},*/
'editaccountpanel #formcancel':{
'click':function(){
// Ext.getCmp('editaccountpanel').setVisible(false);
Ext.getCmp('main').setHeight(100);
}
},

'accountpanel #edit1':{
'click':function(d){
Ext.getCmp('preference').setHeight(250);
Ext.getCmp('formpre').setVisible(true);

}
},


'accountpanel #formcancel1':{
'click':function(d){
Ext.getCmp('formpre').setVisible(false);
Ext.getCmp('preference').setHeight(100);
}
},


'cancel #cancel1':{
'click':function(d){
this.getChrome().getLayout().setActiveItem(0);
}
}

});
}
});

//Json

{
'success': true,
'results': [
{'id':1, 'name': 'India'}
]

}



1.I want to get the data in the textfield from the store.How can i get it can any one help me.Where should my code can any one help me its urgent.
I have attached the snapshot.

scottmartin
10 Oct 2012, 9:52 AM
Did you want to look through the store fields and get the values, or can you use form.getValues()

In what context ..

Scott.

patel1990
10 Oct 2012, 11:11 PM
I want to retrive the text field value and then i will edit that value and that edited value should be stored in the store on the save button click..