1. #1
    Sencha User
    Join Date
    Aug 2012
    Location
    Pune, India
    Posts
    78
    Answers
    5
    Vote Rating
    0
    Pravin.Pawar is on a distinguished road

      0  

    Default 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

  2. #2
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      1  

    Default


    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:

    Code:
    onButtonclick: function(button) {
      var form = button.up('myformXtype'),
        field = form.down('textfield[name=someName]');
    
      form.doStuff();
      field.doOtherStuff();
    }
    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's

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,649
    Answers
    3454
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by flanders View Post
    If possible, always try to work relatively.
    Wow, that's a hell of a lot better way to explain it than what I was always trying

    +1 for the suggestion!
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #4
    Sencha User
    Join Date
    Aug 2012
    Location
    Pune, India
    Posts
    78
    Answers
    5
    Vote Rating
    0
    Pravin.Pawar is on a distinguished road

      0  

    Default


    Thanks for suggestions.
    Thanks, Pravin

Thread Participants: 2