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 6605397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:16:45+00:00 2026-05-25T19:16:45+00:00

I have a simple example here with a modal window that is a ‘view’.

  • 0

I have a simple example here with a modal window that is a ‘view’. I want to have a button within the window that does a window close, so the lazy user doesn’t need to click the ‘X’ in top right.

My problem is I don’t know how to reference the view from within the controller. In the non-MVC world I would just do a ‘window.close()’ in the button handler. Any ideas? Thanks!

View

   Ext.define('AM.view.testwindow.window', {
    extend: 'Ext.window.Window',
    alias: 'widget.TESTwindow',
    title: 'TEST Window',
    layout: 'border',
    width: 1000, height: 400,
    minimizable: true,
    maximizable: true,
    closeAction: 'destroy',
    initComponent: function () {
        this.items = [

        {xtype: 'gridpanel', region: 'center',    // grid in the window
        store: 'Equipments',
        columns: [
          { text: 'Equip ID',  dataIndex: 'EquipmentID' }
          , {  text: 'StationID',     dataIndex: 'StationID' }
        ],

        dockedItems: [{
            xtype: 'toolbar',         // Grid's toolbar
            items: [
            {
                  xtype: 'button',              /* Close button to close the window */
                  text: 'Close Window',
                  itemId: 'btnTestClose'
              }
           ]
        }
      ]
    }
    ];
    this.callParent(arguments);
}
}); 

Controller

  Ext.define('AM.controller.testwindow', {
    extend: 'Ext.app.Controller',
    stores: ['Equipments', 'Stations'],
    models: ['Equipment'],
    views: ['testwindow.window', 'testwindow.Grid'],
    refs: [
    {        ref: 'TESTgrid',     selector: 'TESTgrid'   },
        {    ref: 'testwindow',   selector: 'testwindow'  }
    ],

    init: function () {

        this.control(
        {
            '#btnTestClose': {
                click: function (butt, e, options) {
                    alert('close handler!');
                    this.getTestwindowWindowView().close();   // this fails.   What should I do? ComponentQuery ?
                 }
            }

        }
        )
    }
}
);

Scope of ‘this’ from within Button handler

Scope of 'this' from within Button handler

  • 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-05-25T19:16:46+00:00Added an answer on May 25, 2026 at 7:16 pm

    Your ref to the test window should match the alias TESTwindow (without the widget part), or maybe the long name testwindow.window:

    refs: [
        {    ref: 'TESTgrid',     selector: 'TESTgrid'   },
        {    ref: 'TESTwindow',   selector: 'testwindow'  }
    ],
    

    This will give you the autogenerated getter you need:

    this.getTestwindow().close();
    

    Getters are composed of get plus the reference selector with uppercase first letter.

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

Sidebar

Related Questions

Here is a simple example: Assume I have a customer table that has a
Does anyone have a simple example of implementing an async validation rule in csla?
I have this very simple example that I am using to learn structs in
Have a look at this very simple example WPF program: <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml
Here's simple view model that I use: public class ViewModel { public Order Order
I'm using this simple modal dialog example here: http://jqueryui.com/demos/dialog/modal-form.html When the page loads, jQuery
I have seen simple example Ajax source codes in many online tutorials. What I
I have this simple example I can't seems to get working : MERGE INTO
Below I have a very simple example of what I'm trying to do. I
A simple example: Let's say I have one alias being sourced somewhere as: alias

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.