This is a migrated thread and some comments may be shown as answers.

grid empty result response handling

5 Answers 801 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 18 May 2012, 04:18 PM
Any one else noticed that if the grid receives an empty result set crashes? Say one of the filters returns zero results it all goes south, is there a way to save it? It returns this error : Uncaught TypeError: Cannot read property 'length' of undefined  

5 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 24 May 2012, 08:38 AM
so no one else has a similar issue? The grid becomes unusable this way and i think that the admins should give us a hint on how to prevent this.
0
Adrian
Top achievements
Rank 1
answered on 31 May 2012, 10:07 PM
I am looking for the same as well.

Note this similar post for the error:
http://www.kendoui.com/forums/ui/grid/xml-binded-datasource-with-empty-data-doesn-t-work-in-grid.aspx
0
Adrian
Top achievements
Rank 1
answered on 31 May 2012, 10:53 PM
Here is a solution posted in another thread I came up with for handling empty grid data:
http://www.kendoui.com/forums/ui/grid/xml-binded-datasource-with-empty-data-doesn-t-work-in-grid.aspx#2130759
0
Michael
Top achievements
Rank 1
answered on 01 Jun 2012, 07:13 AM
Thanks for that, but not exactly a clean solution, i have gone this way eventually, but i don't like the way it turned out. Appart from the extra code, you have to control the grid from the "outside" which is not the best idea when you want to take advantage of the component.
0
Michael
Top achievements
Rank 1
answered on 04 Jun 2012, 12:46 PM
The following worked for me. Inside the schema config do this :
data : function(data) {
     if (data.results.length == 0) {
    return [];
    }
return data.results;
}

provided of course that you expect the results note as a source for the grid
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Adrian
Top achievements
Rank 1
Share this question
or