PDA

View Full Version : Setting window field values from controller



invictvs
10 Sep 2013, 8:36 AM
I have a window that displays values about a user in a popup when a certain cell is clicked.. in my UserController I load a json of the user based on id, is there any way to pass particular values of this json into my window? I know I could use .getForm().setValues() if it were a form. Can I nest a form inside my window?

Controller snippet:

loadUserDetails: function(userId) {
var view = Ext.widget('userdetails').show();
Ext.Ajax.request({
url: /user/get.htm?alt=json',
params: { id: userId },
success: function(response) {
var json = Ext.decode(response.responseText);
}
});
}


View snippet (window):

Ext.define('App.view.user.UserDetails', {
extend: 'Ext.window.Window'
,alias: 'widget.userdetails'
,id: 'userdetails'
,title: 'User Details'
,height: 300
,width: 380

,initComponent: function() {
var me = this;
this.items = [{
xtype: 'fieldset',
title: 'Information',
margin: '5',
width: 350,
height: 250,
defaults: {xtype: 'displayfield', margin: '3', labelWidth: 100, width: 300},
items: [{
id: 'id',
width: 150,
fieldLabel: 'User Id'
},{
id: 'userDetailData.email',
width: 250,
fieldLabel: 'User Email'
}]

}];
this.callParent(arguments);
}
});

ettavolt
10 Sep 2013, 9:11 PM
Instead of extending Window, extend a form.Panel and specify a bunch of options like floating, draggable, modal, etc.