View Full Version : update 'emptyText' value dynamically

21 Jun 2010, 2:23 AM
Hi All,

I want to update the grid's 'emptyText' value once I get the response back from server.

Currently I am using 'emptyText' as below to show message to the user initially when request is not made.

for example ::

viewConfig: {
deferEmptyText: false,
emptyText: "Please select country"

Once the user selects the 'country' from dropdown, I am making a server call to get the required values(here it is states). If the server response is zero records then I want to show the different message to user saying 'There are no states'. For this I need to update the 'emptyText' value dynamically.

I tried many ways but in vain.

Please anyone suggest me here.


21 Jun 2010, 2:35 AM
grid.getView().emptyText = 'Some text';

21 Jun 2010, 4:37 AM
thnx Condor.

I am getting 'grid is not defined' error. I tried putting grid name also but its not working. :(

plz help me.

21 Jun 2010, 4:51 AM
My example assumed that you assigned the gridpanel instance to a variable named 'grid'.

Does your grid have an id so you can use Ext.getCmp()?

21 Jun 2010, 10:03 PM

I tried but still getting the error - Ext.getCmp("exGrid").getView is not a function


21 Jun 2010, 10:56 PM
Are you sure exGrid is the id of the grid? And has the grid been created from it's config object?

27 Apr 2013, 12:33 AM
I have the same issue. I would like to change dynamically the emptyText depending on the response of the server (sometimes syntax error, sometimes empty field...etc).

My code :

panel.store.on('load', function(store, records, options) {

if( store.getProxy().getReader().jsonData.error)
emptyText = ERROR_SYNTAX
else if( store.getProxy().getReader().jsonData.results && store.getProxy().getReader().jsonData.results.length == 0)
emptyText = ERROR_NO_RESULTS ;

if(emptyText != "")
panel.viewConfig.emptyText = emptyText;

}, panel);

As you can see, after each reload of the store, i check the answer and change the emptyText. The thing is that it works but one time later, for sure because of a refresh but i can't figure out how to do it. In few words, after the first server response if i have a syntax error, the emptyText will display the welcome message. Then if I query again, and the server response is an empty results, the panel will display the syntax error of before... and so on (1 time later).

I tried panel.getView().refresh : no errors, but does nothing
I tried panel.viewConfig.applyEmptyText(): applyEmptyText is not a function
I tried panel.applyEmptyText() : applyEmptyText is not a function

Can someone solved this issue ?
Thank you.

25 Sep 2013, 3:13 PM
grid.getView().emptyText = 'Some text';grid.getView().refresh();