1. #1
    Ext User
    Join Date
    Mar 2009
    Posts
    4
    Vote Rating
    0
    nuinisk is on a distinguished road

      0  

    Default Cannot apply Grid columns from ajax request

    Cannot apply Grid columns from ajax request


    hi all .
    I have some problem realted with grid headers. or may be not...

    this is my existing code
    Code:
    RegionsGrid =Ext.extend(Ext.grid.GridPanel, {    
            id                  : 'regions'
            ,border              : false
            ,store            : regionsGridStore
    //        ,columns          : [{header: 'Barev'}]
            ,enableDragDrop   : true
            ,stripeRows       : true
    //        //,autoExpandColumn : 'name'
            ,width            : 200
            ,title            : 'Regions'
            ,initComponent: function(){        
    //    
    //            Ext.apply(this,{
    //                columns : [{header: 'Name'}]
    //            });
    //            
                Ext.Ajax.request({
                    scope:this,
                    url : '../server/data.php',
                    method: 'POST',
                    success:  function( result, request ) {
                        Ext.apply(this,{
                            columns : [{header: 'Name'}]
                        });
                    }
                });
                          
                RegionsGrid.superclass.initComponent.apply(this, arguments);
            }
    }); // e/o extend
    
    Ext.reg('regionsGrid', RegionsGrid);
    this bring some error with cm...
    seems that i cannot apply columns from ajax request.
    how i undertand it must work, because i pass 'this' to ajax.request via scope.
    realy i want to get column names from ajax request.
    when i am applying columns from initComponent it works fine.

    I hope you understand what i mean.

    Thanks
    Last edited by nuinisk; 22 Apr 2009 at 12:33 PM. Reason: sorry i am using ext 2.x

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,503
    Vote Rating
    49
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Did you read the Important note in the API description of Ext.Ajax.request?

  3. #3
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    If you're interested in information from the server to build the grid, maybe you'd be interested in the discussion about metaData in the docs for JsonReader/JsonStore. There's a sample implementation in my signature (metaGrid).

Thread Participants: 2