-
5 Dec 2012 7:22 AM #1
Unanswered: Alternative way for Ext.getCmp
Unanswered: Alternative way for Ext.getCmp
Hi,
I have lot of controls in ExtJS form which are placed inside different panels. Following is my code for one of the panel-
var pnlCIRT = new Ext.Panel({
region: 'south',
id: 'detailpanel',
collapsible: false,
autoScroll: true,
layout: 'vbox',
height: 300,
title: 'CIRT Details',
items: [{
xtype: 'fieldcontainer',
layout: 'hbox',
items: [{
xtype: 'displayfield',
id: 'dfdate',
name: 'date',
fieldLabel: 'Date',
labelWidth: 120,
value: date,
width: 143
}, {
xtype: 'splitter',
width: 200
}, {
xtype: 'displayfield',
id: 'dfcirtnumber',
name: 'cirtnumber',
fieldLabel: 'CIRT Number',
value: CIRTNumber,
labelWidth: 180,
width: 120
}]
At this point; I'm using Ext.getCmp('dfcirtnumber').setValue(results.CIRTNumber); to read the control and set value.
I think; Ext.getCmp is NOT a good practice to read and set control values if there are huge amount of controls used within a form.
Please let me know if there is any way to get and set value of control using the panel name so that I can directly get control from the panel itself.Thanks, Pravin
-
5 Dec 2012 2:25 PM #2Sencha User
- Join Date
- Dec 2009
- Location
- Enschede, The Netherlands
- Posts
- 327
- Vote Rating
- 11
- Answers
- 16
If possible, always try to work relatively. For example if you need to update a form title on a button click, work relatively from the button:
If you really need to work globally you can use Ext.ComponentQuery which can also search for a component type with some specific attributes removing the need for globally unique id'sCode:onButtonclick: function(button) { var form = button.up('myformXtype'), field = form.down('textfield[name=someName]'); form.doStuff(); field.doOtherStuff(); }
-
7 Dec 2012 7:47 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,637
- Vote Rating
- 435
- Answers
- 3106
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.
-
14 Dec 2012 4:53 AM #4
Thanks for suggestions.
Thanks, Pravin


Reply With Quote
