1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    25
    Answers
    1
    Vote Rating
    0
    shensi is on a distinguished road

      0  

    Default Answered: How to access to a parameter defined into a parent element

    Answered: How to access to a parameter defined into a parent element


    Hi,
    With a piece of code It will be easier to explain...

    I have many tabs, in each of them I declared an id dID.

    Code:
    items.push({
        inTab: true,
        xtype: 'devicelog',
        device: device,
        dID: dID,
        closable: false,
        listeners: {
            scope: this
        }
    });
    devicelog is my child form panel. I would like to access to this parent variable (dID).

    This dID value should be associated to this data parameter as showed below.
    Code:
    {
        xtype: 'button',
        text : 'On',
        //parentContainer:this,
        //enableToggle: true,
        /*handler: function() {
            alert('You clicked the button!')
        },*/
        listeners: {
            click: function() {
                // this == the button, as we are in the local scope
                //this.setText('On '+this.parentContainer.getId());
                Ext.Ajax.request({
                    method:'PUT',
                    type:'rest',
                    url: 'app.php/execs',
                    params: {
                        data: Should-be-the-dID-parameter,
                        action:'on'
                    },
                    success: function(response){
                        var text = response.responseText;
                        // process server response here
                    }
                });
            }
        }
    },
    Do you know which method can I use to get the dID value ?
    Thank you for your help and your time !
    Shensi

  2. Hi shensi,

    You just simply find the parent panel which contain dID property like...

    Code:
    var  id = childFormPanel.findParentByType('tabpanel').dID;
    For more information see http://docs.sencha.com/ext-js/4-0/#!...d-findParentBy

  3. #2
    Sencha User
    Join Date
    Nov 2011
    Location
    Cuttack,Odisha,India
    Posts
    61
    Vote Rating
    1
    debabrata is on a distinguished road

      0  

    Default


    First access the devicelog component and then with dot operator access the diD config.

  4. #3
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Answers
    124
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default Use findParentByType() method

    Use findParentByType() method


    Hi shensi,

    You just simply find the parent panel which contain dID property like...

    Code:
    var  id = childFormPanel.findParentByType('tabpanel').dID;
    For more information see http://docs.sencha.com/ext-js/4-0/#!...d-findParentBy
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  5. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    25
    Answers
    1
    Vote Rating
    0
    shensi is on a distinguished road

      0  

    Default


    Hi sword-it,

    I tried what you said, but it still doesn't work :-(

    This is my modification and my understanding :

    Code:
    {                xtype: 'fieldset',
                    //flex: 1,
                    title: 'Quick test',
                    defaultType: 'checkbox', // each item will be a checkbox
                    layout: 'anchor',
                    items: [
                    {
                        xtype: 'button',
                        text : 'On',
                        //parentContainer:this,
                        //enableToggle: true,
                        handler: function(btn, e) {
                            //This is an alias of my tabpanel item -> firebug says : btn.findParentByType("deviceinfotab") is undefined
                            var id = btn.findParentByType('deviceinfotab').dID;
                            //This is an alias of a deviceinfo tabpanl which contain all tabs -> firebug says : the console says 'undefined' without error
                            var id = btn.findParentByType('deviceinfo').dID;
                            console.log(id);
                        },
                        listeners: {
                            click: function() {
                                // this == the button, as we are in the local scope
                                //this.setText('On '+this.parentContainer.getId());
                                Ext.Ajax.request({
                                    method:'PUT',
                                    type:'rest',
                                    url: 'app.php/execs',
                                    params: {
                                        data: this.id,
                                        action:'on'
                                    },
                                    success: function(response){
                                        var text = response.responseText;
                                        // process server response here
                                    }
                                });
                            }
                        }
    
                    },


    This is the modification of my tab item :

    Code:
    items.push({    inTab: true,
        alias: 'widget.deviceinfotab',
        xtype: 'deviceaction',
        device: device,
        dID: dID,
        closable: false,
        listeners: {
            scope: this
        }
    });


    Hope I will find soon...
    Cheers

  6. #5
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Answers
    124
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Did you try to debug:
    Code:
    var parent = btn.findParentByType('deviceinfotab');
    if 'deviceinfotab' is found and it contains dID property then you can get the dID value. That would certainly work.

    According to your latest code you can try the following:
    Code:
    var id = btn.findParentByType('deviceaction').dID;
    Last edited by sword-it; 24 May 2012 at 5:12 AM. Reason: misspelling
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  7. #6
    Sencha User
    Join Date
    Feb 2012
    Posts
    25
    Answers
    1
    Vote Rating
    0
    shensi is on a distinguished road

      0  

    Default


    Nice one boss,

    It was exactly this line to write :

    Code:
    var id = btn.findParentByType('deviceaction').dID;
    Thank you very much for your help

Thread Participants: 2

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