1
votes

i am using this code :

grid.render('grid');
Ext.getCmp('grid').mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');

As per the documentation

emptyText : String Default text (html tags are accepted) to display in the grid body when no rows are available (defaults to ''). This value will be used to update the mainBody:

this.mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');

for me it shows

Cannot read property 'update' of undefined

Please help

1
What is this? We may need more code to go on but it looks like whatever this is doesn't contain a definition of mainBody - weeksdev
i was trying this ,, but later i come to know about deferEmptyText : false and emptyText :'no data found' ..... need to write them in viewConfig{}. - sparsh610
show us your grid class to explain the reason behind this error. Only can be said through the piece of code you put above is that mainBody does not refer a rendered object. - talha06

1 Answers

0
votes

In this snippet, render is asynchronous. Therefore, mainBody does not yet exist when it is called on the next line.

grid.render('grid');
 Ext.getCmp('grid').mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');

Also, ExtJs should handle emptyText itself, so I don't get why it is necessary to update the mainBody with emptyText anyway.