PDA

View Full Version : Ext.create for items?



castitas
6 Aug 2012, 9:02 AM
Is there a difference in speed/etc in using xtype versus Ext.widget()/Ext.create() in the items array? I think that xtype is the standard...



Ext.define('util.FutTimeGrid',{
extend: 'Ext.grid.Panel',
alias : 'widget.futtimegrid',
...



...
xtype: 'tabpanel',
items: [{
xtype: 'futtimegrid', //How is this different...
title: "Regular Time",
itemId: 'regtimegrid',
gridStore : myRsce.regTimeStore,
totalStore: myRsce.regTimeTotalStore,
employeeId: this.employeeId,
isEditable: this.isEditable
},
Ext.widget('futtimegrid',{ //from this?
title: "Overtime",
itemId: 'overtimegrid',
gridStore : myRsce.otStore,
totalStore: myRsce.otTotalStore,
employeeId: this.employeeId,
isEditable: this.isEditable
})
,
...

scottmartin
6 Aug 2012, 9:57 AM
Create will create an instance at that time, whereas xtype will load the item only when needed.

It also allows you to call a custom class in a simple manner instead of creating many lines of code to do the same thing.

Scott.

castitas
7 Aug 2012, 7:33 AM
I see. So xtype would be preferable where you don't want the object created until it needs to be, as in a tabpanel, right?

scottmartin
7 Aug 2012, 8:55 AM
Correct.

Scott.