0
votes

I have a trouble about render a grid with toolbar in a collapsible panel. As you see on code at bottom, I have reader, store, grid with bbar and panel. When I set collapsible property of panel to false grid's toolbar render perfectly. But, when I set panel collapsible property to true then I expand panel, I can not see the toolbar. I want to show grid with toolbar and data on panel expand without any trouble. How can I repair this code?

Thx all.

var reader_DailyActivity = new Ext.data.JsonReader({
    totalProperty       : 'total',
    successProperty : 'success',
    root            : 'data',
    fields          : [
                        {name: 'date'},
                        {name: 'time'},
                {name: 'description'},
                {name: 'speed'},
                {name: 'distance'},
                {name: 'type'},
                {name: 'source'}
            ]
});

var store_DailyActivity = new Ext.data.Store({
    id      : 'dailyActivityStoreID',
    reader      : reader_DailyActivity
});

var pagingToolbar = new Ext.PagingToolbar({
    pageSize    : 20,
    buttonAlign     : 'center',
    store       : store_DailyActivity
});

var DailyActivityGrid = new Ext.grid.GridPanel({
    id          : 'dailyActivityGrid',
    store           : store_DailyActivity,
    loadMask        : true,
    height          : 300,
    autoScroll      : true,
    viewConfig      : { 
        emptyText       : 'No Record Found',
        deferEmptyText  : false,
        forceFit        : true
    },
    columns         :[
                    {header: 'Date', dataIndex: 'date'},
                    {header: 'Time', dataIndex: 'time'},
                    {header: 'Description', dataIndex: 'description'},
                    {header: 'Speed', dataIndex: 'speed'},
                    {header: 'Distance', dataIndex: 'distance'},
                    {header: 'Type', dataIndex: 'type'},
                    {header: 'Source', dataIndex: 'source'}
                ],
    bbar        : pagingToolbar
});

var VehicleDetail = new Ext.Panel({
    title       : 'Activity Details',
    id      : 'panel_DetailID',
    collapsible : true,
    collapsed   : true,
renderTo    : 'renderedDivID',
    items       : DailyActivityGrid,
    listeners   : {
        'expand' : function(hede)
        {
            var panelMask = Ext.getCmp('panel_DetailID');
            // mask grid panel
            panelMask.getEl().mask('Please Wait');

        Ext.Ajax.request({                 
                url: 'url comes here',
                params: 
                {
                    param1  : reqParam1,
            start   : 0,
            limit   : 20
                },
                success: function (result, request) 
                {                   
                    var resData = Ext.util.JSON.decode(result.responseText);
                    store_DailyActivity.loadData(resData);
                    // unmask grid panel
                    panelMask.getEl().unmask();
                },
                failure: function ()
                {
                    console.log('error');
                }
        });
        }
    }
});
2

2 Answers

4
votes

Please try to remove the height of the GridPanel. I experienced the same issue in RowExpander Where I was trying to load grid on expander. In my case, Grid displayed fine but tbar & bbar were not displaying due to height constraints. Therefore, I tried to remove the height of the grid and it brought success for me. Your issue looks similar to mine, so please try this suggestion. Hope it works!

1
votes

Couple things you can try:

  1. Give the containing panel a layout config layout: 'fit'.
  2. Use explicit docked items i.e., delete bbar: pagingToolbar and put in this:
dockedItems: [{
    xtype: 'pagingtoolbar',
    dock: 'bottom',
    pageSize: 20,
    buttonAlign: 'center',
    store: store_DailyActivity
}],