1. #1
    Sencha User
    Join Date
    Sep 2008
    Location
    China
    Posts
    8
    Vote Rating
    0
    hongwenchina is on a distinguished road

      0  

    Default [4.1/4.1.1 BUG] Grouped Grid scrolls to first row when value of a field changed

    [4.1/4.1.1 BUG] Grouped Grid scrolls to first row when value of a field changed


    Hi,
    please run the following code, and then scroll the grid to the last row.
    when you click the tbar button 'click' to change the value of a field (not the groupField),
    the grid will scrolls to the first line.

    In my project ,i use the grouped grid to monitor the system status every 2 seconds.
    so , the last row of it can hardly be shown.

    It works fine on Ext4.1 Beta. when i update to 4.1.1 today, I found it works abnormally.

    thanks



    Code:
    Ext.require(['Ext.data.*', 'Ext.grid.*']);
    Ext.onReady(function() {
        // wrapped in closure to prevent global vars.
        Ext.define('Restaurant', {
            extend: 'Ext.data.Model',
            fields: ['name', 'cuisine']
        });
        var data = [];
        for(i=0;i<50;i++)
        {
            data.push({
                name: 'Cheesecake Factory',
                cuisine: 'Group ' + (i%10)
            });
        }
        var Restaurants = Ext.create('Ext.data.Store', {
            storeId: 'restaraunts',
            model: 'Restaurant',
            groupField: 'cuisine',
            sorters: ['cuisine','name'],
            data: data
        });
        
        var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
            groupHeaderTpl: 'Cuisine: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})',
            hideGroupedHeader: true
        });
    
        var grid = Ext.create('Ext.grid.Panel', {
            renderTo: Ext.getBody(),
            collapsible: true,
            iconCls: 'icon-grid',
            frame: true,
            store: Restaurants,
            width: 600,
            height: 400,
            title: 'Restaurants',
            resizable: true,
            features: [groupingFeature],
            columns: [{
                text: 'Name',
                flex: 1,
                dataIndex: 'name'
            },{
                text: 'Cuisine',
                flex: 1,
                dataIndex: 'cuisine'
            }],
            fbar  : ['->', {
                text:'Clear Grouping',
                iconCls: 'icon-clear-group',
                handler : function(){
                    groupingFeature.disable();
                }
            }],
            tbar:[{
                text:'click',
                handler: function(){
                    var record = Restaurants.getAt(Restaurants.getCount()-1);
                    record.set('name','test');
                    record.commit();
                }
                
            }]
        });
    });

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,935
    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


    Add the following to your grid:

    Code:
    viewConfig: {
        preserveScrollOnRefresh : true, 
    },
    Regards,
    Scott.

  3. #3
    Sencha User
    Join Date
    Sep 2008
    Location
    China
    Posts
    8
    Vote Rating
    0
    hongwenchina is on a distinguished road

      0  

    Default


    Scott,

    Thank you very much, it works now with your code.

Thread Participants: 1