Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:07:15+00:00 2026-06-17T23:07:15+00:00

I have been using extjs’s Ext.getCmp(‘xtypeid’).getValue(); Ext.getCmp(‘xtypeId’).setValue(”); to get a value or set a

  • 0

I have been using extjs’s

Ext.getCmp('xtypeid').getValue();
Ext.getCmp('xtypeId').setValue('');

to get a value or set a value… I just found out that. this is a bad programming in terms of OOP… but my question is how do you go about getting value or setting values bunch of textbox. It would be great if someone could show me a sample program doing just this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:07:16+00:00Added an answer on June 17, 2026 at 11:07 pm

    They are required here cause it happens more than just setting the value. Please keep in mind that JavaScript is a Prototype-based programming language so you cannot compare it with a OOP article that you may have read for Java or C#.

    What is bad is the use of getCmp() you should avoid that if possible and completely use ComponentQuery or encapsulating refs. And if possible avoid setting id by yourself if not strictly required. With component query you can query for any custom or common property. For example the itemId is in addition supported by ExtJS and for buttons I use a custom property called action

    You should not concern about methods provided by the framework, do it when you extend or create classes and follow the patterns there.

    For clarification: Ext.getCmp() is not the bad thing, it is really fast, bad is fact that most people set the id by them self so that they can use getCmp() which can lead to duplicated id’s and that is a problem.

    Update

    As mentioned in the comment the Ext.ComponentQuery is quite mighty and flexible. I will not cover all in this view lines, just one basic example.

    Lets make a simple environment. We have a class called Custom which we have extended from Panel. Custom has a Toolbar in the top dockedItems and a Toolbar in the bottom dockedItems.

    Ext.define('Custom', {
        extend: 'Ext.panel.Panel',
        alias: 'widget.custom',
    
        tbar: {
            itemId: 'top-bar',
            items: [{
                text: 'foo',
                action: 'foo'
            },{
                text: 'bar', 
                action: 'bar'
            }]  
        },
        dockedItems: [{
            xtype: 'toolbar',
            itemId: 'bottom-bar',
            dock: 'bottom',
            items: [{
                text: 'foo-bottom',
                action: 'foo'
            },{
                text: 'bar-bottom', 
                action: 'bar'
            }]  
        }],
    
        initComponent: function() {
            this.callParent(arguments);
        }
    });
    

    Now we are creating instances from our new Class and how it come, we have two instances on screen at the same time.

    Ext.create('Custom', {
        title: 'Panel',
        itemId: 'first',
        height: 100,
        width: 400
    });
    Ext.create('Custom', {
        title: 'Other Panel',
        itemId: 'second',
        height: 100,
        width: 400
    });
    

    Now you want to subscribe yourself to button-events within a centralized class but you will need to identify each button for that. You might have seen that I defined some properties like itemId (which is really known by ExtJS and can also be used two query on just one component. See the API) and action. These are names that I use but you might use any here. And now we build our unique path to query with. We will do this for the ‘foo’ button in the bottom Toolbar of the first panel:

    First we know that we are looking for a panel. You might say hey we are looking for custom cause that’s our class. But that doesn’t matter cause the ComponentQuery looks if the class is extended from panel. But this is the first point where we can reduce our first result set and we will do this choosing the xtype of our extend class custom.

    'custom'
    

    We now get all instances of the class Custom or any class that extend it. Now that are too much, we need one. So we add a filter property.

    custom[itemId=first]
    

    Now we have the first Panel. Let’s do the same for the toolbar and the button

    custom[itemId=first] > toolbar[itemId=bottom-bar] > button[action=foo]
    

    And that’s pretty much is it.

    See the JSFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using Selenium a lot lately (testing an ExtJs app) and while
I have been using a reset CSS set of styles for quite some time
I have been using the following function to get regular parameters from the current
Hello I have been using JQuery for quite a while. I need to get
We're using jQuery on a less UI-intensive project whereas we have been using ExtJS
We've just started using Sencha's ExtJS 4 in our project and have been following
I have been using the jQuery Docs and I am trying to set up
I have been using TortoiseSVN for some time and I really like it. I
I have been using Stanford POS Tagger to tag parts of speech in a
I have been using play 1.2.5rc4 for development of one app and I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.