-
6 Jan 2011 5:56 PM #1
Clone an ExtJS Component
Clone an ExtJS Component
I know this way but what if I haveCode://Component 1 var comp1 = new Ext.form.TextField({}); //Component cloning... var comp2 = comp1.cloneConfig();
How can I clone this object?Code:{ xtype: 'form', region:'center', labelWidth: 125, frame: true, title: 'Date Range', bodyStyle:'padding:5px 5px 0', labelPad: 20, layoutConfig: { labelSeparator: '' }, defaults: { width: 230, msgTarget: 'side' }, defaultType: 'datefield', items: [{ fieldLabel: 'Start Date', name: 'startdt', id: 'startdt', vtype: 'daterange', endDateField: 'enddt' // id of the end date field },{ fieldLabel: 'End Date', name: 'enddt', id: 'enddt', vtype: 'daterange', startDateField: 'startdt' // id of the start date field }] }
More specifically, I concern about how to enhance the reusability of the components.
As the number of components used grows, I have found that it is annoying to do copy and paste and this job even increase the amounts of code line. so I wonder how other peoples work in managing a number of the components.
-
6 Jan 2011 7:30 PM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
If you have reusable bits of code, move them to classes, register xtypes


Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
6 Jan 2011 7:45 PM #3
Your explanation is little bit harder to me to understand.
My case is that when I insert above form panel into several panels, I met some weird situation like duplicate contents, malfunction of event etc. I guess this problem is caused by copying the component. I believe extjs regard these components are the same components so I need to clone the component and make extjs distinguish these two components as well as dwindle the amount of code line.
-
6 Jan 2011 9:05 PM #4
Jgarcia has a great video tutorial on exactly this subject. Check it out on tdg-I.com. That's what really got me started on extjs.
Look fornthe one about extending and abstract classes.
-
7 Jan 2011 6:41 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Jan 2011 6:43 AM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
7 Jan 2011 6:43 AM #7Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
7 Jan 2011 6:44 AM #8Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Jan 2011 8:06 AM #9
-
7 Jan 2011 8:29 AM #10
Yeah, and after you're done watching the one about abstract classes, watch the one about Ext.getCmp and stop using hard-coded ids at all.
Similar Threads
-
How to clone a Field?
By zhoujianghao in forum Ext GWT: Help & Discussion (1.x)Replies: 6Last Post: 11 Jul 2012, 2:12 AM -
An Open Source Meebo Clone with EXTJS 2.0
By atreyu in forum Community DiscussionReplies: 2Last Post: 16 Nov 2010, 3:23 AM -
Clone
By ibralnet in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 10 Feb 2009, 3:22 AM -
what is the name component used in http://extjs.com/products/extjs/ ?
By wiyanto in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 19 Nov 2008, 7:35 AM


Reply With Quote
Also check out his book (an upcoming books).