1. #1
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      0  

    Default How to access parent container of a toolbar button

    How to access parent container of a toolbar button


    Hi, I'm creating a panel with a toolbar containing buttons. And would like to add a handler to one of the buttons, handler that will access some other part of my panel. I want to do everyting in the config (before the whole GUI is reendered), and can't figure out how to obtain a reference to another part of the gui in the handler function.
    Below is a fragment of my code, hope it will illustrate what I want to do.
    You can see a button with a handler function there.
    In the handler, I' d like to walk up the component hierarchy to find the parent panel, then descend to a child component of that panel with some id. However, both findParentByType, nor findParentBy functions return null when called from the button handler function.
    How to walk the component tree in my case?
    BTW, I want to keep everything in Ext config format (JSON) - no local variables etc.
    THX
    RG

    Code:
    {
      "xtype": "panel",
      "id": "pnl-main",
      "layout": "border",
      "height": 800,
      "border": false,
      "tbar": [
        {
          "xtype": "tbtext",
          "text": "<b>Zadanie 3022</b>"
        },
        {
          "xtype": "tbfill"
        },
        {
          "text": "Akcje",
          "xtype": "splitbutton"
        },
        {
          "text": "Zapisz",
          "xtype": "button"
        },
        {
          "text": "Wyjdź",
          "xtype": "button",
          "handler": 
    						function(b, e) {
    							alert('start: ' + b);
    							var p1 = b.findParentByType('panel');
    							alert('p1: ' + p1);
    							var p = b.findParentBy(function(cn, x) {
    								alert('z');
    								alert("T:" + x.getXType());
    								alert(" id: " + x.id);});
    								return true;
    							}
    					,
          "id": Ext.id()
        }
      ],

  2. #2
    Ext JS Premium Member
    Join Date
    Nov 2008
    Location
    Warsaw area, Poland
    Posts
    64
    Vote Rating
    1
    nightwatch is on a distinguished road

      0  

    Default


    Here's the full code. I want to access 'pnl-info' panel from toolbar button handler and show/hide the 'pnl-info' when button is clicked.

    Code:
    {
      "xtype": "panel",
      "id": "pnl-main",
      "layout": "border",
      "height": 800,
      "border": false,
      "tbar": [
        {
          "xtype": "tbtext",
          "text": "<b>Zadanie 3022</b>"
        },
        {
          "xtype": "tbfill"
        },
        {
          "text": "Akcje",
          "xtype": "splitbutton"
        },
        {
          "text": "Zapisz",
          "xtype": "button"
        },
        {
          "text": "Wyjdź",
          "xtype": "button",
          "handler": 
    						function(b, e) {
    							alert('start: ' + b);
    							var p1 = b.findParentByType('panel');
    							alert('p1: ' + p1);
    							var p = b.findParentBy(function(cn, x) {
    								alert('z');
    								alert("T:" + x.getXType());
    								alert(" id: " + x.id);});
    								return true;
    							}
    					,
          "id": Ext.id()
        }
      ],
      "items": [
        {
          "id": "pnl-info",
          "height": 100,
          "layout": "border",
          "region": "north",
          "border": false,
          "xtype": "panel",
          "items": [
            {
              "region": "north",
              "height": "auto",
              "border": false,
              "collapsible": true,
              "xtype": "panel",
              "style": "padding: 4px 4px 4px 4px",
              "html": "\r\n\t\t\t\t\t<html><body><h1>Odrzuc kandydata: a. Masz 30 sekund.</h1></body></html>\r\n\t\t\t\t\t"
            },
            {
              "height": "auto",
              "region": "center",
              "border": false,
              "xtype": "panel",
              "collapsed": false,
              "html": "\r\n\t\t\t\t\t\t<b>Data utworzenia: </b>2008-11-18 12:18:12<br/>\r\n\t\t\t\t\t\t<b>Odpowiedzialny: </b>Admin<br/>\r\n\t\t\t\t\t"
            }
          ]
        },
        {
          "xtype": "ng-form",
          "width": "auto",
          "height": "auto",
          "region": "center",
          "baseParams": {
            "_objref": "Task!3022",
            "_view": "Task.Details"
          },
          "items": [
            {
              "layout": "column",
              "items": [
                {
                  "layout": "form",
                  "columnWidth": 0.5,
                  "items": [
                    {
                      "fieldLabel": "Id",
                      "xtype": "textfield",
                      "name": "Id",
                      "readOnly": true,
                      "value": 3022
                    },
                    {
                      "fieldLabel": "Data utworzenia",
                      "xtype": "textfield",
                      "name": "CreatedDate",
                      "readOnly": true,
                      "value": "2008-11-18 12:18:12"
                    }
                  ]
                },
                {
                  "layout": "form",
                  "columnWidth": 0.5,
                  "items": [
                    {
                      "fieldLabel": "Status",
                      "xtype": "textfield",
                      "name": "Status",
                      "readOnly": true,
                      "value": "Cancelled"
                    },
                    {
                      "fieldLabel": "Osoba odpowiedzialna",
                      "xtype": "textfield",
                      "name": "Assignee",
                      "readOnly": true,
                      "value": "Admin"
                    }
                  ]
                }
              ]
            },
            {
              "xtype": "panel",
              "name": "Description",
              "fieldLabel": "Opis",
              "height": 200,
              "anchor": "98%",
              "disabled": true,
              "html": "Nowy kandydat: a\nEmail: b\nc"
            }
          ]
        }
      ]
    }

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi