-
13 Sep 2010 3:33 AM #1
[OPEN-1262][3.3] GridView emptyText not working at several levels.
[OPEN-1262][3.3] GridView emptyText not working at several levels.
In a simple Ext page paste this into Firebug:
No text displayed.Code:Ext.getBody().update(''); g = new Ext.grid.GridPanel({title:'Grid', width:600,height:400, columns: [], hideHeaders: true, store: new Ext.data.ArrayStore({fields:[]}), viewConfig: { emptyText: 'Nothing to see here!' }, renderTo: Ext.getBody(), });
So it turns out you have to refresh to get the display. And you HAVE TO defer the call, otherwise it still does not work:
But see how it's wrapped? The body is not sized because there are no columns.Code:Ext.getBody().update(''); g = new Ext.grid.GridPanel({title:'Grid', width:600,height:400, columns: [], hideHeaders: true, store: new Ext.data.ArrayStore({fields:[]}), viewConfig: { emptyText: 'Nothing to see here!' }, renderTo: Ext.getBody(), }); g.view.refresh.defer(1, g.view);
emptyText should not rely on the body being sized to accomodate columns. It should mean that the body is fully expanded. I'm using this to display a fatal I/O error which meant that the grid could not be produced. We couldn't even look up the columns.
So to display some error text in a GridPanel, you finally need the incantation:
emptyText needs a more robust implementation.Code:Ext.getBody().update(''); g = new Ext.grid.GridPanel({title:'Grid', width:600,height:400, columns: [{}], hideHeaders: true, store: new Ext.data.ArrayStore({fields:[]}), viewConfig: { forceFit: true, emptyText: 'Nothing to see here!' // I send exception.getLocalizedMessage in the JSON! }, renderTo: Ext.getBody(), }); g.view.refresh.defer(1, g.view);
I managed to get my error through to the front end eventually:
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
13 Sep 2010 4:18 PM #2
Hrmm we'll take a look at what you're saying about the body being sized.
In regard to the grid and the view not refreshing immediately this is the out of the box behavior. Because you are using an ArrayStore that hasn't been loaded it doesn't know to apply the emptyText (bc the store hasn't been loaded). You can use the deferEmptyText configuration in conjunction with the unloaded store to immediately show the emptyText.Aaron Conran
@aconran
Sencha Architect Development Team
-
13 Sep 2010 4:18 PM #3
Hrmm we'll take a look at what you're saying about the body being sized.
In regard to the grid and the view not refreshing immediately this is the out of the box behavior. Because you are using an ArrayStore that hasn't been loaded it doesn't know to apply the emptyText (bc the store hasn't been loaded). You can use the deferEmptyText configuration in conjunction with the unloaded store to immediately show the emptyText.Aaron Conran
@aconran
Sencha Architect Development Team
-
14 Sep 2010 1:18 AM #4
That makes sense! The Store has to have an attempted load to know that it is in fact empty, not just in a default state.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
27 Oct 2010 8:00 AM #5
Another issue, is that id the results are "null" and not a empty array, it does not apply the emptyText...
-
28 Oct 2010 5:16 AM #6
That is a Reader issue, and it's a moot point as to whether it should handle that as you say.
To correctly indicate that zero rows were returned as the result of a successful query which happened to yield zero rows, I suggest that it is necessary to receive a success packet containing a zero length array.Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
29 Oct 2010 6:08 AM #7
I'm happy you feel that way. But That doesn't necessarily mean it isn't a bug. IMO, returning no rows is more accurate then returning an empty array. I think it is a preference of a development team's code style.
Also IMO, if something is "moot" or ambiguous, then it should be handled either way. Causes less frustration, and less confusion.
-
19 May 2012 3:19 PM #8
Any Solution to display messages when the grid has no records
Any Solution to display messages when the grid has no records
Animal,
Was wondering if you found any better solution to display a message in the body of a Grid Panel when there are no data records to display than using the Grid View's emptyText attribute. I.e. in the case of an error or other condition that prevents the data from being retrieved.
I my case I have a 'Search Results' Grid Panel that displays a number of records from the user's search along with a tab panel where individual tabs have additional Grid Panels. Depending on which record the user has selected in the search results gird panel, there may or may not be records to display in each of the various tabbed grid panels for multiple reasons (lots of optional child tables).
I'd like to display a message in the active tab's gird panel (that would vary from record to record selected in the search results grid panel) and have been able to by setting deferEmptyText to false, changing the emptyText value, then calling refresh... but this seems like a kludge and I haven't been able to figure out how to add some padding to the grid panel to the message isn't right up against the top and left side of the grid panel.
Any suggestions would be much appreciated.
Regards,
--Greg-- Once you go Mac, you never go back!
-
27 May 2012 7:56 AM #9
You can just drop HTML into the View's el.
Code:myGrid.getView().el.update('Boo!');Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
Updating a gridview's emptyText?
By kmoncada in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 6 Feb 2009, 10:15 AM -
GridView and emptyText
By sl5337 in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 2 Oct 2008, 7:04 AM -
[2.0] Possible bug in GridView (not render emptyText string)
By haattila in forum Ext 2.x: BugsReplies: 3Last Post: 19 Jan 2008, 4:24 AM -
[2.0b1] GridView emptyText feature
By tjcrowder in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 29 Oct 2007, 2:03 PM


Reply With Quote