1. #11
    Sencha User
    Join Date
    Jul 2011
    Posts
    19
    Vote Rating
    0
    jayapal is on a distinguished road

      0  

    Default I am sorry

    I am sorry


    I just posted in Ext forum, I dint notice the forum version.
    Yes I am using 3.2.1.

    Can you help me to fix this issue in 3.21 version ?

    thanks in advance

  2. #12
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,747
    Vote Rating
    106
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default


    Your code works fine for me in firebug, getCmp returns the expected grid component.

  3. #13
    Sencha User
    Join Date
    Jul 2011
    Posts
    19
    Vote Rating
    0
    jayapal is on a distinguished road

      0  

    Default why its not working for me?

    why its not working for me?


    Can you check your EXT js version ? Mine is 3.2.1
    Its throws error. I got stuck in this issue for last 2 days.

  4. #14

  5. #15
    Sencha User
    Join Date
    Jul 2011
    Posts
    19
    Vote Rating
    0
    jayapal is on a distinguished road

      0  

    Default whats solution for me?

    whats solution for me?


    How can I fix?

  6. #16
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,747
    Vote Rating
    106
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default


    What line throws the error? How have you debugged this?

  7. #17
    Sencha User
    Join Date
    Jul 2011
    Posts
    19
    Vote Rating
    0
    jayapal is on a distinguished road

      0  

    Default firbug + firefox

    firbug + firefox


    throws error on the line which highligted in red color
    i.e. var grid=Ext.getCmp("My_Grid_Panel").getView();

  8. #18
    Sencha - Community Support Team mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    2,747
    Vote Rating
    106
    mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all mankz is a name known to all

      0  

    Default


    You're doing it backwards. I'm guessing getState gets called as soon as you create the toolbar. At this time the grid hasn't yet been registered with the component manager (i.e. Ext.getCmp is called too early).

    You should clean your code up and make sure you do things in the right order. A quick hack that might get this working is to assign a local variable to your grid.

    Code:
    MyPanel = Ext.extend(Ext.grid.GridPanel, {
      pageSize: 30,
        dataLoaded: false,
        stateful: true,
        stateId: "my_state_id_grid",
         initComponent: function() {
            var grid = this;
            Ext.QuickTips.init();
            Ext.apply(this, {
                store: {
                    xtype: 'jsonstore',
                    totalProperty: 'total',
                    proxy: new Ext.data.HttpProxy({
                        method: 'GET',
                        disableCaching: false,
                        url: '/xx/xx/xx'
                }),
                root: 'fields',
                fields: ['xxx']
                },
                colModel: new Ext.grid.ColumnModel([
                    {
                        header: 'xxx',
                        dataIndex: 'xxx',
                        width: 100,
                        sortable: true,
                        hidden: true
                    }
                ]),
                selModel: new Ext.grid.RowSelectionModel({
                    singleSelect: true
                }),
                iconCls: 'icon-grid',
                loadMask: true,
                autoScroll: true,
                viewConfig: {
                    forceFit: true
                }
            });
            this.plugins = [new Sleuth.filter.GridFilters({
                local: false,
                stateful: true,
                stateId: 'state_id_grid_filter',
                encode: true,
                filters: [
                    {type: 'string', dataIndex: 'xxx'},
                ],
            })];
            this.bbar = new Ext.PagingToolbar({
                    pageSize: this.pageSize,
                    stateId: 'my_id_pagin',
                    stateful: true,
                    store: this.store,
                    displayInfo: true,
                    plugins: this.plugins,
                    xtype: 'paging',
                stateEvents: ["change"],
    
                getState: function() {var state = Ext.state.Manager.getProvider();
                           state.set('startStore',this.store.lastOptions.params.start);
                           
                           state.set('active_field', grid.filters.keyTracker[0]);
                           return {pageSize: this.pageSize};
                           }
    
            });
            MyPanel.superclass.initComponent.apply(this, arguments);
            this.on({afterlayout: {single: true, fn:function() {  
                this.bottomToolbar.bindStore(this.store);
                var state = Ext.state.Manager.getProvider();
                var start = state.get('startStore',0)
                this.getStore().load({params: {start: start, limit: this.pageSize}});
                }
            }});
        }
    });
    
    
    var MyNewPanel = new MyPanel({id:'My_Grid_Panel',pageSize: 40});

  9. #19
    Sencha User
    Join Date
    Jul 2011
    Posts
    19
    Vote Rating
    0
    jayapal is on a distinguished road

      0  

    Default another error

    another error


    If I use local variable then I am getting error as,
    grid.grid is undefined

    [IMG]chrome://firebug/content/blank.gif[/IMG] state.set('active_field',grid.grid.filters.keyTracker[0]);

    Can you tell me how my script got worked for you ? Did you made any changes?

  10. #20
    Sencha User
    Join Date
    Jul 2011
    Posts
    19
    Vote Rating
    0
    jayapal is on a distinguished road

      0  

    Default


    Quote Originally Posted by mankz View Post
    You're doing it backwards. I'm guessing getState gets called as soon as you create the toolbar. At this time the grid hasn't yet been registered with the component manager (i.e. Ext.getCmp is called too early).
    In my grid i have a button to clear the filter, in which I tired to access the grid the same procedure
    [CODE]
    this.bbar = new Ext.PagingToolbar({
    pageSize: this.pageSize,
    stateId: 'my_id_pagin',
    stateful: true,
    store: this.store,
    displayInfo: true,
    plugins: this.plugins,
    xtype: 'paging',
    items:[
    '-', {
    enableToggle:false,
    text: 'Clear Filter',
    handler: function(btn, pressed){
    var grid=Ext.getCmp("ext-comp-1001").getView();
    grid.grid.filters.clearFilters();

    }
    },....
    [CODE]

    But throws same error. I hope this time the grid would have registered with component manager.

Thread Participants: 1

Tags for this Thread