Not able to access object from data in ViewModel - extjs

Am trying to fetch the persondetails details into enableButton method.
Am aware that we can achieve this by simply adding key and value to data object.
But my question here is, is there any way to store data into persondetails and fetch it?
If I specify as below and bind accordingly, then its wok fine.
data: {
firstname: '',
lastname: ''
}
bind: {
value: '{lastname}'
},
Here is the code:
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.define('MyApp.view.TestViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.userinfo',
data: {
persondetails:{
firstname: '',
lastname: ''
}
},
formulas: {
enableButton: function(get){
debugger;
if(get('firstname')!=='' && get('lastname')!=='' ){
return true;
}else{
return false;
}
},
fullName: function(get){
if(get('firstname')!=='' && get('lastname')!=='' ){
return get('firstname') + ' ' + get('lastname');
}
}
}
});
Ext.create('Ext.form.Panel', {
title: 'Contact Info',
width: 500,
bodyPadding: 10,
renderTo: Ext.getBody(),
viewModel:{
type:'userinfo'
},
items: [{
xtype: 'textfield',
name: 'firstname',
emptyText: 'Enter First Name',
bind: {
value: '{persondetails.firstname}'
},
}, {
xtype: 'textfield',
name: 'lastname',
emptyText: 'Enter Last Name',
bind: {
value: '{persondetails.lastname}'
},
}, {
xtype: 'button',
reference: 'clickme',
disabled: true,
bind: {
disabled: '{!enableButton}'
},
text: 'Click',
listeners: {
click: function(){
alert('{fullName}');
}
}
}, {
xtype: 'displayfield',
fieldLabel: 'Full Name',
bind: {
value: '{fullName}'
}
}]
});
}
});
I have created a fiddle Example

According to documentation
When a direct bind is made and the bound property is an object, by
default the binding callback is only called when that reference
changes. This is the most efficient way to understand a bind of this
type, but sometimes you may need to be notified if any of the
properties of that object change.
To do this, we create a "deep bind":
In other words, if a object changes its properties, the viewmodel will not notify these changes (although their properties are changed correctly).
If you need to listen this changes, you need to use deep binding
Ext.application({
name : 'Fiddle',
launch : function() {
Ext.define('MyApp.view.TestViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.userinfo',
data: {
persondetails: {
firstname: '',
lastname: ''
}
},
formulas: {
enableButton: {
bind: {
bindTo: '{persondetails}',
deep: true // listen to any change in personaldetails
},
get: function (data) {
return data.firstname && data.lastname
}
},
fullName: {
bind: {
bindTo: '{persondetails}',
deep: true // listen to any change in personaldetails
},
get: function (data) {
return data.firstname + ' ' + data.lastname
}
},
}
});
Ext.create('Ext.form.Panel', {
title: 'Contact Info',
width: 500,
bodyPadding: 10,
renderTo: Ext.getBody(),
viewModel:{
type:'userinfo'
},
items: [{
xtype: 'textfield',
name: 'firstname',
emptyText: 'Enter First Name',
bind: {
value: '{persondetails.firstname}'
},
}, {
xtype: 'textfield',
name: 'lastname',
emptyText: 'Enter Last Name',
bind: {
value: '{persondetails.lastname}'
},
}, {
xtype: 'button',
reference: 'clickme',
disabled: true,
bind: {
disabled: '{!enableButton}'
},
text: 'Click',
listeners: {
click: function(){
alert('{fullName}');
}
}
}, {
xtype: 'displayfield',
fieldLabel: 'Full Name',
bind: {
value: '{fullName}'
}
}]
});
}
});

Related

extjs binding with formulas

I'm trying to do textfiled binding in extjs with the following conditions.
What i'm doing wrong?
Need to display three textfields where by default 2nd and 3rd textfields will be disabled.
Second textfield should enable only when first field value is entered.
third should be enabled only when first and second values are entered.
the fiddle.
You have forgotten to bind the second field value to 'field2'. This sample works:
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.define('MyViewModel', {
extend: 'Ext.app.ViewModel',
alias: 'viewmodel.myvm',
data: {
field1: '',
field2: '',
field3: ''
},
formulas: {
fieldTwoDisabled: function (get) {
return Ext.isEmpty(get('field1'));
},
fieldThreeDisabled: function (get) {
return !(!Ext.isEmpty(get('field1')) && !Ext.isEmpty(get('field2')));
}
}
});
Ext.create({
xtype: 'panel',
title: 'VM Demo',
fullscreen: true,
defaults: {
xtype: 'textfield'
},
viewModel: {
type: 'myvm'
},
items: [{
label: 'Field 1',
bind: '{field1}'
}, {
label: 'Field 2',
bind: {
value: '{field2}', // THIS BINDING IS FORGOTTEN
disabled: '{fieldTwoDisabled}'
}
}, {
label: 'Field 3',
bind: {
disabled: '{fieldThreeDisabled}'
}
}]
})
}
});

ExtJS: Issue with scope in class

I'm keep facing with a issue to choice exact component with scope. As you'll notice below I've created 2 different functions inside gridpanel. One of those creates a Ext.MessageBox for confirm. And other function creates a Ext.window.Window depends on button click of MessageBox.
The thing here is; It should destroy related component with cancel and no buttons. Both buttons always point to gridpanel because of var me = this state and destroys the gridpanel itself.
How can I point destroy method directly to related component?
Ext.define('MyApp.FooGrid', {
extend: 'Ext.grid.Panel',
reference: 'fooGrid',
getGridMenu: function () {
// Here is the 'Update' function; with right-click user being able to see `contextmenu`
var me = this;
var ret = [
{
text: 'Update',
listeners: {
click: me.onUpdate,
scope: me
}
}
];
return me.callParent().concat(ret);
},
onUpdate: function () {
var me = this,
gridRec = this.getSelectionModel().getSelection(); // Here being able to retrieve row data.
Ext.MessageBox.confirm(translations.confirm, translations.confirmChange, me.change, me);
return gridRec;
},
change: function (button) {
var me = this;
var selectedRec = me.onUpdate();
var selectedRecEmail = selectedRec[0].data.email; //Retrieves selected record's email with right-click action
if (button === "yes") {
return new Ext.window.Window({
alias: 'updateWin',
autoShow: true,
title: translations.update,
modal: true,
width: 350,
height: 200,
items: [
{
xtype: 'container',
height: 10
},
{
xtype: 'textfield',
width: 300,
readOnly: true,
value: selectedRecEmail //Display selected record email
},
{
xtype: 'textfield',
width: 300,
fieldLabel: translations.newPassword
}
],
dockedItems: [
{
xtype: 'toolbar',
dock: 'bottom',
items: [
{
xtype: 'tbfill'
},
{
xtype: 'button',
text: translations.cancel,
listeners: {
click: function () {
me.destroy(); // Here is the bug: When user clicks on this button; should destroy current window but it destroys 'gridpanel' itself
}
}
},
{
xtype: 'button',
text: translations.save,
listeners: {
click: function () {
console.log("I'll save you!");
}
}
}
]
}
]
});
} else {
console.log('this is no!');
me.destroy(); // Another bug raises through here: If user will click on No then 'messagebox' should destroy. This one is destroys the gridpanel as well.
}
}
});
How can I point destroy method directly to related component?
Firstly on confirmation box button's(No) click, you don't need to destroy it will automatically hide the box whenever you click into No.
And for update window instead of using me.destroy() you need to use directly button.up('window').destroy() so it will only destroy your update window not the grid.
And also you don't need to again call me.onUpdate() inside of change function otherwise it will again show the confirmation box. You can directly get selected record on the change function like this me.getSelection().
In this Fiddle, I have created a demo using your code and I have put my efforts to get result.
CODE SNIPPET
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('Ext.data.Store', {
storeId: 'demostore',
fields: ['name', 'email', 'phone'],
data: [{
name: 'Lisa',
email: 'lisa#simpsons.com',
phone: '555-111-1224'
}, {
name: 'Bart',
email: 'bart#simpsons.com',
phone: '555-222-1234'
}, {
name: 'Homer',
email: 'homer#simpsons.com',
phone: '555-222-1244'
}, {
name: 'Marge',
email: 'marge#simpsons.com',
phone: '555-222-1254'
}]
});
Ext.create('Ext.grid.Panel', {
title: 'Demo GRID',
store: 'demostore',
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Email',
dataIndex: 'email',
flex: 1
}, {
text: 'Phone',
dataIndex: 'phone'
}],
height: 200,
listeners: {
itemcontextmenu: function (grid, record, item, index, e, eOpts) {
e.stopEvent();
grid.up('grid').getGridMenu().showAt(e.getXY());
}
},
renderTo: Ext.getBody(),
getGridMenu: function () {
var me = this;
if (!me.contextMenu) {
me.contextMenu = Ext.create('Ext.menu.Menu', {
width: 200,
items: [{
text: 'Update',
handler: me.onUpdate,
scope: me
}]
});
}
return me.contextMenu;
},
onUpdate: function () {
var me = this;
Ext.MessageBox.confirm('Confirmation ', 'Are your sure ?', me.change, me);
},
change: function (button) {
var me = this,
selectedRecEmail = me.getSelection()[0].data.email; //Retrieves selected record's email with right-click action
if (button === "yes") {
return new Ext.window.Window({
autoShow: true,
title: 'Update',
modal: true,
width: 350,
height: 200,
items: [{
xtype: 'tbspacer',
height: 10
}, {
xtype: 'textfield',
width: 300,
readOnly: true,
value: selectedRecEmail //Display selected record email
}, {
xtype: 'textfield',
inputType:'password',
width: 300,
fieldLabel: 'New Password'
}],
dockedItems: [{
xtype: 'toolbar',
dock: 'bottom',
items: [{
xtype: 'tbfill'
}, {
xtype: 'button',
text: 'cancel',
listeners: {
click: function (btn) {
btn.up('window').destroy(); // Here is the bug: When user clicks on this button; should destroy current window but it destroys 'gridpanel' itself
}
}
}, {
xtype: 'button',
text: 'save',
listeners: {
click: function () {
console.log("I'll save you!");
}
}
}]
}]
});
}
}
});
}
});

extjs6 modern card layut

I am new in Extjs. I have a container with card layout with 3 sub views including a grid, a form for creating and a form for updating using route.
items: [
{xtype: 'feature-grid',id:'feature-grid},
{xtype: 'create-form'},
{xtype: 'update-form'}
],
it works well at the first time but when I change the route and switch to this route again this error appears:
Uncaught Error: DOM element with id feature-grid in Element cache is not the same as element in the DOM. Make sure to clean up Element instances using destroy()
and when I remove the id the save button in my create form doesnt add record to the grid without any error!
my save button is like this:
var form = button.up('formpanel');
var values = form.getValues();
var user = Ext.create('App.model.User',values);
var cntr = this.getView('UserContainer')
var mainpanel = button.up('user-container');
var grid = mainpanel.down('grid');
grid.store.add(user);
form.reset();
this.redirectTo('users')
any idea?
As you are using routes so in this case first you need to check you view is already created or not. If view is already created then you can use that view otherwise you can create view.
In this FIDDLE, I have create a demo using cardlayout, grid and form. I hope this will help/guide you to achieve your requirement.
CODE SNIPPET
Ext.application({
name: 'Fiddle',
launch: function () {
//Define cotroller
Ext.define('MainController', {
extend: 'Ext.app.ViewController',
alias: 'controller.maincontroller',
routes: {
'application/:node': 'onViewChange'
},
//this event will fire whenver routing will be changed
onViewChange: function (xtype) {
var view = this.getView(),
newNode = view.down(xtype);
//if view is not crated then 1st created
if (!newNode) {
newNode = Ext.create({
xtype: xtype
});
}
// is new view is form then first reset the form
if (newNode.isXType('form')) {
newNode.reset();
}
// if new view type is update-form then load the record
if (xtype == 'update-form') {
newNode.setRecord(this.record)
this.record = null;
}
//If view is created then directly set active that view
view.setActiveItem(newNode);
},
//this event will fire when main view render
onMainViewAfterRedner: function () {
this.redirectTo('application/feature-grid');
},
//this event will fire when grid items clicked
onGridItemClick: function (grid, index, target, record, e, eOpts) {
this.record = record;
this.redirectTo('application/update-form');
},
//this event will fire when cancel button clicked
onCancelButtonClick: function () {
this.redirectTo('application/feature-grid');
},
//this event will fire when add new button clicked
onAddNew: function () {
this.redirectTo('application/create-form');
},
//this event will fire when save button clicked
onSaveButtonClick: function (button) {
var me = this,
form = button.up('formpanel'),
store = me.getView().down('grid').getStore(),
values = form.getValues();
if (form.xtype == 'update-form') {
store.findRecord('id', values.id).set(values);
} else {
if (values.name && values.email && values.phone) {
delete values.id;
store.add(values);
} else {
Ext.Msg.alert('Info','Please enter form details');
return false;
}
}
this.onCancelButtonClick();
}
});
Ext.define('AppForm', {
extend: 'Ext.form.Panel',
layout: 'vbox',
bodyPadding: 10,
defaults: {
xtype: 'textfield',
//flex: 1,
width: '100%',
margin: '10 5',
labelAlign: 'top',
allowBlank: false
},
items: [{
name: 'id',
hidden: true
}, {
name: 'name',
label: 'Name'
}, {
name: 'email',
label: 'Email'
}, {
name: 'phone',
label: 'Phone Number'
}, {
xtype: 'toolbar',
defaults: {
xtype: 'button',
ui: 'action',
margin: 5,
flex: 1
},
items: [{
text: 'Save',
formBind: true,
handler: 'onSaveButtonClick'
}, {
text: 'Cancel',
handler: 'onCancelButtonClick'
}]
}]
});
//this create-form.
Ext.define('CreateForm', {
extend: 'AppForm',
alias: 'widget.create-form',
title: 'Create form'
});
//this update-form.
Ext.define('UpdateForm', {
extend: 'AppForm',
alias: 'widget.update-form',
title: 'Update form'
});
//this feature-grid.
Ext.define('fGrid', {
extend: 'Ext.panel.Panel',
alias: 'widget.feature-grid',
title: 'User List grid',
layout: 'vbox',
items: [{
xtype: 'grid',
flex: 1,
store: {
fields: ['name', 'email', 'phone'],
data: [{
name: 'Lisa',
email: 'lisa#simpsons.com',
phone: '555-111-1224'
}, {
name: 'Bart',
email: 'bart#simpsons.com',
phone: '555-222-1234'
}, {
name: 'Homer',
email: 'homer#simpsons.com',
phone: '555-222-1244'
}, {
name: 'Marge',
email: 'marge#simpsons.com',
phone: '555-222-1254'
}]
},
columns: [{
text: 'Name',
dataIndex: 'name',
flex: 1
}, {
text: 'Email',
dataIndex: 'email',
flex: 1
}, {
text: 'Phone',
dataIndex: 'phone',
flex: 1
}],
listeners: {
itemtap: 'onGridItemClick'
}
}],
tools: [{
type: 'plus',
iconCls: 'x-fa fa-plus',
handler: 'onAddNew'
}],
flex: 1
});
//Define the main view form extending panel
Ext.define('MainView', {
extend: 'Ext.panel.Panel',
controller: 'maincontroller',
alias: 'widget.mainview',
layout: 'card',
listeners: {
painted: 'onMainViewAfterRedner'
}
});
//this will create main view that is card layout
Ext.create({
xtype: 'mainview',
renderTo: Ext.getBody(),
fullscreen: true
});
}
});

Why does Ext.getCmp(...).setChecked cause errors

I'm trying to set the checked state of an ExtJS 6.2 radiofield dynamically when a window is loaded for editing user information.
My window code is as follows
Ext.define('scim.view.users.EditUserWdw', {
extend: 'Ext.window.Window',
alias: 'widget.EditUserWdw',
id: 'editUserWdw',
required: [
'scim.view.users.UserController',
'Ext.form.Panel'
],
width: 400,
listeners: {
beforeclose: function (wdw) {
var frm = this.down('form');
if (frm.isDirty()) {
Ext.Msg.show({
title: 'Confirm Cancel',
msg: '<p>You started editing a user. Closing this window now will cause you to lose any information you changed.</p><p>Are you sure?</p>',
icon: Ext.Msg.QUESTION,
buttons: Ext.Msg.YESNO,
fn: function (ans) {
if (ans == 'yes') {
frm.reset();
wdw.close();
}
}
});
return false;
} else {
return true;
}
}
},
items: [{
xtype: 'form',
reference: 'form',
id: 'editUserFrm',
border: false,
style: 'background-color: #fff',
url: '/scim_libs/Users.php?metho=updateUser&userId=' + sessionStorage.userId,
padding: 5,
bbar: ['->', {
xtype: 'button',
text: 'Update User',
iconCls: 'x-fa fa-save',
handler: function () {
var frm = this.up('form');
if (frm.isValid()) {
frm.submit({
success: function (frm, response) {
var jData = Ext.util.JSON.decode(response.resposnse.responseText);
if (jData.status == "duplicate") {
Ext.Msg.show({
title: 'Duplicate Email',
msg: '<p>The email address <strong>' + Ext.getCmp('editUserEmail').getValue() + '</strong> is already used by another user.</p><p>Please use a different email address and try adding the user again.</p>',
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
closable: false,
fn: function () {
Ext.getCmp('editUserEmail').focus();
this.close();
}
})
}
else if (jData.status == "success") {
Ext.getStore('User').load();
Ext.Msg.show({
title: 'User Added',
msg: '<p>The user <strong>' + Ext.getCmp('editUserFirstName').getValue() + ' ' + Ext.getCmp('addUserLastName').getValue() + '</strong> has been updated successfully.</p>',
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK,
fn: function () {
Ext.getCmp('addUserFrm').reset();
Ext.getCmp('addUserWdw').close();
}
})
} else {
Ext.Msg.show({
title: 'Unexpected Error!',
msg: '<p>An unexpected error occurred when trying to update the user <strong>' + Ext.getCmp('addUserFirstName').getValue + ' ' + Ext.getCmp('adduUserLastName').getValue() + '</strong>. Please try updating the user again.</p><p>Should this problem persist, please contact technical support and provide the following information:</p><p>' + jData.status + '</p>',
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
fn: function () {
Ext.getCmp('addUserFrm').reset();
Ext.getCmp('addUserWdw').close();
}
})
}
}
})
}
}
}, {
xtype: 'button',
text: 'Cancel',
iconCls: 'x-fa fa-ban',
handler: function () {
this.up('form').up('window').close();
}
}],
items: [{
xtype: 'textfield',
anchor: '100%',
name: 'editUserFirstName',
id: 'editUserFirstName',
fieldLabel: 'First Name',
allowBlank: false,
minLength: 2,
madLength: 65,
selectOnAutoFocus: true,
listeners: {
afterrender: function () {
this.focus(true);
}
}
}, {
xtype: 'textfield',
anchor: '100%',
name: 'editUserLastName',
id: 'editUserLastName',
fieldLabel: 'Last Name',
allowBlank: false,
minLength: 2,
maxLength: 65
}, {
xtype: 'textfield',
anchor: '100%',
name: 'editUserEmail',
id: 'editUserEmail',
fieldLabel: 'Email',
allowBlank: false,
maxLength: 255,
selectOnFocus: true,
vtype: 'email'
}, {
xtype: 'textfield',
anchor: '100%',
name: 'editUserPhone',
id: 'editUserPhone',
fieldLabel: 'Phone',
maskRe: /[0-9]/,
regexText: 'Numbers Only',
allowBlank: true,
vtype: 'phone',
maxLength: 14,
listeners: {
change: function () {
if (this.getValue().length == 3) {
this.setValue('(' + this.getValue() + ') ');
}
if (this.getValue().length == 9) {
this.setValue(this.getValue() + '-');
}
}
}
}, {
xtype: 'fieldcontainer',
fieldLabel: 'Reset Password',
itemId: 'editUserResetGrp',
defaults: {
flex: 1
},
layout: 'hbox',
width: 200,
items: [{
xtype: 'radiofield',
boxLabel: 'Yes',
name: 'editUserReset',
inputValue: 1,
id: 'editUserReset1'
}, {
xtype: 'radiofield',
boxLabel: 'No',
name: 'editUserReset',
inputValue: 0,
id: 'editUserReset2'
}]
}, {
xtype: 'fieldcontainer',
fieldLabel: 'Lock Account',
defaults: {
flex: 1
},
layout: 'hbox',
width: 200,
items: [{
xtype: 'radiofield',
boxLabel: 'Yes',
name: 'editUserLocked',
inputValue: 0,
id: 'editUserLocked1'
}, {
xtype: 'radiofield',
boxLabel: 'No',
name: 'editUserLocked',
inputValue: 1,
id: 'editUserLocked2'
}]
}]
}]
})
My controller code is
Ext.define('scim.view.users.UserController', {
extend: 'Ext.app.ViewController',
alias: 'controller.user',
addUser: function () {
var addUserWdw = Ext.create('scim.view.users.AddUserWdw', {
title: 'Add New User'
}).show();
},
editUser: function (grid, rowIndex, colIndex) {
var objRow = Ext.getStore('User').getAt(rowIndex);
var editUserWdw = Ext.create('scim.view.users.EditUserWdw', {
title: 'Edit User - ' + objRow.data.userFirstName + ' ' + objRow.data.userLastName
}).show();
Ext.getCmp('editUserFirstName').setValue(objRow.data.userFirstName);
Ext.getCmp('editUserLastName').setValue(objRow.data.userLastName);
Ext.getCmp('editUserEmail').setValue(true);
Ext.getCmp('editUserPhone').setValue('(' + objRow.data.userPhone.substr(0, 3) + ') ' + objRow.data.userPhone.substr(3, 3) + '-' + objRow.data.userPhone.substr(6, 4));
console.log(objRow.data.reset);
if (objRow.data.reset == 0) {
console.log(Ext.getCmp('editUserReset2'));
console.log(Ext.getCmp('editUserReset2').checked);
Ext.getCmp('editUserReset2').setChecked(true);
console.log(Ext.getCmp('editUserReset2').checked);
} else {
console.log(Ext.getCmp('editUserReset1'));
}
},
getUsers: function () {
Ext.getStore('Users').load();
}
})
When running
console.log(Ext.getCmp('editUserReset2').checked)
The results received are as expected "false".
console.log(Ext.getCmp('editUserReset2').setChecked(true)
triggers then the error returned is
Uncaught TypeError: Ext.getCmp(...).setChecked is not a function
I've tried getting the fieldcontainer and then an array of radiofield's and using setChecked(index, true) with the same results.
I've checked the documentation and it is a method to this xtype. So I've become stumped in where this error is generating from. Any help would be greatly appreciated.
Thanks #EvanTrimboli for the following answer...
I was using the documentation on Sencha's website for the Modern Toolkit which uses the
Ext.getCmp(...).setChecked(true)
While my code is actually using the Classic Toolkit which uses the
Ext.getCmp(...).setValue(value)
As the means of setting a radio button checked state.

create Custom Component and re use it

i am new to ext, i want to create a custom component containing a form and use it by registering it as a xtype, where i want:
MyComponent = Ext.extend(Ext.FormPanel, {
initComponent: function () {
Ext.apply(this, {
labelWidth: 50,
// label settings here cascade unless overridden
items: [{
xtype: 'label',
text: 'Name'
},
{
xtype: 'textfield',
label: 'First Name',
name: 'firstname',
id: 'firstname',
allowBlank: true
},
{
xtype: 'label',
text: 'Last Name',
style: {
'color': 'black',
'font-size': '10px'
}
},
{
xtype: 'textfield',
label: 'lastname',
name: 'lastname',
id: 'lastname'
},
{
xtype: 'label',
text: 'Teams'
},
{
xtype: 'button',
text: 'Save',
handler: function () {},
id: 'save',
},
{
xtype: 'button',
text: 'cancel',
handler: function () { //Ext.Msg.alert('Status', 'Changes saved successfully.');
Ext.example.msg(' Click', 'You cancelled');
}
}
]
});
MyComponent.superclass.initComponent.apply(this, arguments);
},
onRender: function () {
MyComponent.superclass.onRender.apply(this, arguments);
}
});
Ext.reg('mycomponentxtype', MyComponent); /* paste in your code and press Beautify button */
if ('this_is' == /an_example/) {
do_something();
} else {
var a = b ? (c % d) : e[f];
}
When i create my own Components i do this:
Ext.define('MyApp.view.dialog.MyDialog', {
'extend' : 'Ext.window.Window',
'alias' : 'widget.MyDialog',//declare xour own xtype here
'title' : 'My Dialog',
'items' : [{
'xtype' : 'textfield',
'fieldLabel' : 'Surename',
//other config here
}] // other items here
});
Then you can say:
Ext.widget('MyDialog').show();

Resources