• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

ExtJS 5 View Controller - getting References

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ExtJS 5 View Controller - getting References

    Trying to get accustomed to ExtJS's new way of handling references...I like it. One thing that is throwing me off, is how do i get a reference to a component that lives in another parent view? I have a main panel with form.....then I have a search window (pop up) that displays a grid (helps the user search for records). What is proper way to get a reference to the form in the mainPanel from the window using the concept of view controllers?

    Thank you!

    Ryan

  • #2
    Hi Ryan -

    Technically, a component that lives under a different parent should not be attempting to get a reference to a component that lives under another structure. The view should be able to live on its own without any knowledge of the "outside world".

    In the scenario you described, I would recommend one of two options:

    Option 1
    Your "main" controller instantiates the window that contains the grid. When it instantiates the window, attach a listener for an event...let's call it "itemselected". Have your window fire off the "itemselected" event when the user selects a row in the grid passing the record that was selected. Now your "main" controller function handles closing the window and accepting the row parameter to populate your form.

    Option 2 - Probably preferred in your case
    When your "main" controller instantiates the window, make the window a child of the "main" view. Since a window is a "floating" component, you can simply add the window to the view and it will not affect any of your layouts.

    Code:
    me.getView().add({
       xtype : 'mywindow'
    }).show();
    Now your "main" controller is handling the window so you can easily access any of the components living under "main".


    Hope this makes sense.

    Comment


    • #3
      This is exactly what I needed to know.
      Thanks.

      Comment

      Working...
      X