2
votes

I want to implement grid bufferrenderer in my simple grid panel that shows a list of information using ExtJS 4.2.1. Without using the bufferrenderer plugin, it shows all the data, but when i used this plugin, my grid contains no data.

This is my grid without using the plugin

enter image description here

This is my grid using the plugin

enter image description here

The grid panel's code is:

Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.panel.Panel',
itemId: 'myPanel',
title: '',
requires: ['Ext.grid.plugin.BufferedRenderer'],
initComponent: function() {
    var me = this;
    Ext.applyIf(me, {
        items: [
            {
                xtype: 'gridpanel',
                autoRender: true,
                autoShow: true,
                itemId: 'gridPanel',
                title: 'My Grid Panel',
                store: 'MyJsonStore',
                columns: [
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'id',
                        text: 'Id'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'firstName',
                        text: 'FirstName'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'middleName',
                        text: 'MiddleName'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'lastName',
                        text: 'LastName'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'age',
                        text: 'Age'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'country',
                        text: 'Country'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'city',
                        text: 'City'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'street',
                        text: 'Street'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'mobile',
                        text: 'Mobile'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'phone',
                        text: 'Phone'
                    },
                    {
                        xtype: 'gridcolumn',
                        dataIndex: 'zip',
                        text: 'Zip'
                    }
                ],
                plugins: 'bufferedrenderer'
                /*plugins:  {
                    ptype: 'bufferedrenderer',
                    trailingBufferZone: 20,  
                    leadingBufferZone: 25  
                }*/
            }
        ]
    });

    me.callParent(arguments);
}

});

The Store's code is:

Ext.define('MyApp.store.MyJsonStore', {
extend: 'Ext.data.Store',

requires: [
    'MyApp.model.GridModel'
],

constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
        autoLoad: true,
        model: 'MyApp.model.GridModel',
        storeId: 'MyJsonStore',
        buffered: true,
        clearOnPageLoad: false,
        clearRemovedOnLoad: false,
        leadingBufferZone: 25,
        pageSize: 500,
        purgePageCount: 10,
        trailingBufferZone: 20,
        proxy: {
            type: 'ajax',
            url: 'data/users.json',
            reader: {
                type: 'json',
                root: 'users',
                totalProperty: 'total_user'
            }
        }
    }, cfg)]);
}
});

Can anyone help me with this? Thanks

2

2 Answers

2
votes

Setting the height property in grid will fix this issue.

height: 300

1
votes

Make sure that all panels up to the viewport have their layout set to “fit”. Also, region of the grid should be “center”.

I have not tested, but something like this should work:

var grid = Ext.create('MyApp.view.MyPanel', {
     layout: 'fit',
     region: 'center'
     });
var viewport = Ext.create('Ext.container.Viewport', {
        renderTo: Ext.getBody(),
        items: [
            grid
            ]
        });