PDA

View Full Version : Cannot get GridPanel to show emptyText



KallDrexx
30 Dec 2010, 8:53 AM
I have the following grid panel


Ext.onReady(function () {
Ext.QuickTips.init();

var outGrid = new TROutstandingGrid();
outGrid.render('outstandingRequestsGrid');
});

TROutstandingGrid = Ext.extend(Ext.grid.GridPanel, {
store: new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: baseUrl + '/TestRequests/GetOutstandingRequests',
method: 'POST'
}),
autoLoad: true,
root: 'data',
fields: ['id', 'name', 'createdby', 'scheduledtime']
}),

columns: [{
id: 'id',
header: 'Id',
dataIndex: 'id'
}, {
id: 'name',
dataIndex: 'name',
header: 'Name'
}, {
id: 'createdby',
dataIndex: 'createdby',
header: 'Created By'
}, {
id: 'scheduledtime',
dataIndex: 'scheduledtime',
header: 'Scheduled Time'
}],

viewConfig: {
forceFit: true,
emptyText: 'No Outstanding Automation Requests'
},

// Display parameters
title: 'Outstanding Automated Test Requests',
collapsible: true
});

When the JsonStore is run, the following json is being returned:

{"success":true,"data":[]}

Even though there is no data being returned, the empty text message will not show. It did show up once, but since the gridPanel was small I added a height to the grid, and I have yet to be able to get it to show up again. No javascript exceptions are being reported by Chrome.

Does anyone have any idea what I am doing wrong?

Condor
30 Dec 2010, 8:55 AM
Your grid needs a height (or autoHeight:true).

ps. You should not put object (like store, columns and viewConfig) in the prototype. Create them in the constructor or initComponent.

KallDrexx
30 Dec 2010, 8:59 AM
Your grid needs a height (or autoHeight:true).

Adding a height or autoHeight did not make the emptyText appear, but I can see that the height parameters are being taken.

*edit*: it seems to be somewhat random. I saw the EmptyText message appear a few times, but upon refreshing it now doesn't show.



ps. You should not put object (like store, columns and viewConfig) in the prototype. Create them in the constructor or initComponent.

Any reason why? This is exactly how it's done in a lot of the examples on Sencha's own demo page.

KallDrexx
30 Dec 2010, 9:12 AM
I turned autoloading off and put grid.store.load() in my Ext.onReady(), and my emptyText shows consistently now.