开发者

Grid Panel Scrollbars in Extjs 4 not working

var gus开发者_StackOverflowersPanel = Ext.create('Ext.grid.Panel', {
    flex:1,
    columns: [{
        header: 'User Login',
        dataIndex: 'user_login',
        width:150
    },{
        header: 'User Name',
        dataIndex: 'user_nicename',
        width:150
    },{
        header:'Privledge',
        dataIndex:'admin',
        width:150
    }],
    autoScroll: true,
    layout:'fit',
    selModel: gusersSel,
    store: gusersStore

})

Hi I am using above code for the grid Panel in Extjs4.0.2a When I populate data dynamically in the store the scrollbars are not working . I have also tried using doLayout() for grid Panel but dosent work too . The grid Panel is in a Window .

Anything that can solve this problem ?

Actually it works for some time but dosen't work all the time .


I've had the same problem. They use custom scrollbar and it's pretty buggy (especialy in chrome). If you are not going to use infinite scroll the possible solution could be to remove custom scrollbar and use native one. To do that just add the following to the grid's config:

var gusersPanel = Ext.create('Ext.grid.Panel', {
  scroll          : false,
  viewConfig      : {
    style           : { overflow: 'auto', overflowX: 'hidden' }
  },
  // ...
});


I did gusersPanel.determineScrollbars() when i am adding and removing data from store and it is working fine .


The problem with this is the scroll listener is attached to the div element on the afterrender event, but then if the scrollbar is not needed after a layout operation the div element is removed from the dom. Then, when it's needed again it's added back, but only if enough time has passed the garbage collection makes extjs recreate the div node and this time it's added to the dom without attaching the scroll listener again. The following code solves the problem:

Ext.override(Ext.grid.Scroller, {
    onAdded: function() {
        this.callParent(arguments);
        var me = this;
        if (me.scrollEl) {
            me.mun(me.scrollEl, 'scroll', me.onElScroll, me);
            me.mon(me.scrollEl, 'scroll', me.onElScroll, me);
        }
    }
});


You written code to layout: 'fit'. It did not work autoScroll.

Change the code to some height and remove layout: 'fit' code.

Like this.

var gusersPanel = Ext.create('Ext.grid.Panel', {
    flex:1,
    columns: [{
   ...........
    }],
autoScroll: true,
//layout:'fit',
height: 130,
selModel: gusersSel,
store: gusersStore

It is help you. Cheers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜