26

I'm using Extjs gridPanel to display data. I want to show "No data..." message in gridPanel when no data available. How to do this ?.

I tried emptyText property but its not worked.

I think emptyText is for gridView not for gridPanel.

Please help me how to show empty data message in gridPanel.(I'm using gridPanel not grid View)

nani1216
  • 261
  • 1
  • 3
  • 4

1 Answers1

44

You answered your own question -- it is indeed a GridView property. So to specify it in the GridPanel (which uses a GridView internally) just do this:

myGrid = new Ext.GridPanel({
    viewConfig: {
        emptyText: 'No records'
    }
});

Per the comments below, you might also include deferEmptyText: false in the viewConfig for the text to render immediately (otherwise it waits until after the initial store load is complete).

Brian Moeskau
  • 20,103
  • 8
  • 71
  • 73
  • 2
    It seems that you might need call "refresh" on the view of the grid (and defer it) in order to see the empty message: e.g. `myGrid.view.refresh.defer(1, ,myGrid.view);` see [sencha forum](http://www.sencha.com/forum/showthread.php?109611-OPEN-1262-3.3-GridView-emptyText-not-working-at-several-levels.) – Mark Rhodes Jul 06 '11 at 10:39
  • 12
    As the link by **Mark Rhodes** also mentions, you can configure your `viewConfig` to also include the parameter `deferEmptyText: false` which will display the empty text immediately. – Chau Nov 21 '11 at 11:29
  • 8
    Came here from a google search, just want to point out this still works in Ext4 (4.0.7 to be precise) – Matt Greer Nov 27 '11 at 23:54
  • The deferEmptyText: false did it for me!! I feel it is un-*******-believable they put it on true by default! Cost me an hour! :-((( – Lawrence Dec 12 '13 at 14:42
  • I can only concur about the defer stuff. I must be missing something as I don't even get why such a thing is needed in the first place... – Lawrence Feb 25 '14 at 14:38
  • @Lawrence Loading a store from a remote source for the first time. Do you want to show a message saying "No items exist?" while the store is loading? At that point you don't know, you need to wait until the load has completed. – Evan Trimboli Sep 24 '14 at 03:36