1. #1
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    227
    Vote Rating
    2
    nicolabaldo is on a distinguished road

      0  

    Post variable different scope

    variable different scope


    Hi,
    this is my code.
    I need to read records variable when i use dblclick event
    ...
    success: function (response) {
    if (response.responseText!='') {
    var records = Ext.decode( response.responseText );
    var count = records.length;
    var i=0;
    for(i=0;i<count;i++) {
    var obj = [
    {
    id: 'portlet_'+records[i].id,
    itemId: 'portlet_'+records[i].id,
    title: records[i].title,
    items: Ext.create(records[i].portletClass),
    height:200,
    listeners: {
    render: function(c){
    c.el.on('dblclick', function(){
    if (typeof currOspite!="undefined"){
    //here i need to read records variable
    creaWin(records[i].id,records[i].title);
    }
    });
    }}
    }
    ];
    items_to_load.push(obj);
    }

    }
    }
    });
    ...

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,918
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Have a look at the data and items objects

    var jsonData = Ext.util.JSON.decode(xhr.responseText);
    jsonData.data
    jsonData.data.items

    Use firebug to see your data coming back from your server.

    Regards,
    Scott.

  3. #3
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    227
    Vote Rating
    2
    nicolabaldo is on a distinguished road

      0  

    Default


    Sorry but I'dont' understand how i can read the variable "records" declared above..
    ..
    //here i need to read records variable
    creaWin(records[i].id,records[i].title);
    ...

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,918
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Assuming you have a table with abbr,name populated with states

    // make ajax call
    Code:
    handler: function() {
    	Ext.Ajax.request({
    		method: 'POST',
    		url: 'list.php',
    		scope: this,
    		// so we can access ref of field below
    		success: function(xhr) {
    			jsonData = Ext.JSON.decode(xhr.responseText);
    			var records = jsonData.data; // data return from server; see below
    			console.log(records.length); //50
    			console.log(records[0].abbr); // AL
    			console.log(records[0].name); // Alabama
    		}
    	});
    }
    return data from server
    Code:
    listData('states');
        
    function listData($table) 
    {
        $sql = 'SELECT * FROM '.$table;
        
        $result = mysql_query($sql);
        
        while($rec = mysql_fetch_array($result, MYSQL_ASSOC)){
            $arr[] = $rec;
        };
    
        $rows = 50; // hard coded for this example
        $data = json_encode($arr);  //encode the data in json format
          
        echo $cb . '({"total":"' . $rows . '","data":' . $data . '})';
    }
    Regards,
    Scott.

  5. #5
    Ext JS Premium Member
    Join Date
    Dec 2011
    Posts
    227
    Vote Rating
    2
    nicolabaldo is on a distinguished road

      0  

    Default


    I resolved... but I'm not sure it's the correct solution.

    render: function(c){
    c.el.on('dblclick', function(){
    if (typeof currOspite!="undefined"){
    creaWin(records[0].id,records[0].title);
    }
    });
    }}

Thread Participants: 1

Tags for this Thread

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