1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    16
    Vote Rating
    0
    myavuz is on a distinguished road

      0  

    Default scope problem

    scope problem


    I want to reach variable outside the proxy. It is red colored below. How can I use this variable "this" pointer does not work. Thank you..

    Code:
    Ext.define('Confman.view.AuthorPaperList', {
        extend:'Ext.grid.Panel',
        xtype:'authorPaperList',
        width:222,
        height:300,
        testID: 15,
        //store : 'AuthorPaperList',
        store:{
            fields: [{name: 'name',},
                     {name: 'paperId'}
            ],
    
            proxy: {
    
                type: 'ajax',
                url : 'Servlet',
                extraParams: { requestType : testID},
                reader: {                        
                    root: 'rows'
                }
            },
            autoLoad: true    
        },

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    15,103
    Vote Rating
    97
    evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold

      0  

    Default


    You're essentially doing this:

    Code:
    var o = {
        a: 1,
        b: {
            c: a
        }
    };
    It won't be evaluated correctly.

    Instead:

    Code:
    Ext.define('Confman.view.AuthorPaperList', {
        extend:'Ext.grid.Panel',
        xtype:'authorPaperList',
        width:222,
        height:300,
        testID: 15,
        
        initComponent: function() {
            this.store = {
                fields: [{name: 'name',},
                         {name: 'paperId'}
                ],
    
                proxy: {
    
                    type: 'ajax',
                    url : 'Servlet',
                    extraParams: { requestType : this.testID},
                    reader: {                        
                        root: 'rows'
                    }
                },
                autoLoad: true    
            };
            this.callParent();
        }
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    16
    Vote Rating
    0
    myavuz is on a distinguished road

      0  

    Default


    I stated in my question, ' "this" pointer does not work' , I have also tried it. However, here the problem is trying to reach an outer scope which is generally imposibble in programming languages. I just wonder whether we can use up, down functions or not.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    15,103
    Vote Rating
    97
    evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold evant is a splendid one to behold

      0  

    Default


    Please read the code I posted again and try it, it has a different structure to what you're using.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Dec 2012
    Posts
    16
    Vote Rating
    0
    myavuz is on a distinguished road

      0  

    Default


    Hmm, ok, I did not see initComponent sorry, I will try it, thanks