This is a migrated thread and some comments may be shown as answers.
Handling 404 with noRecords template?
2 Answers 17 Views
This is a migrated thread and some comments may be shown as answers.
Miguel
Top achievements
Rank 1
Miguel asked on 11 Sep 2017, 01:05 PM

Hi! I'm using a tiny REST api as the grid's data source. For the API its perfectly fine to return a 404 error if data isn't found, but the grid automatically handles this like a regular error (say, like a 500), instead of letting me handle it through the noRecords template (which is called fine if I return an empty collection instead of a 404 in the API).

How can I handle 404s like how the grid handles empty collections with the noRecords template? 

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 13 Sep 2017, 11:23 AM
Hello Miguel,

In this scenario, I can suggest using the error event of the dataSource. Then check the status of the event and if it is an error, programmatically set the Grid data to an empty array:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events-error

I made an example demonstrating this(please have in mind that there is a small delay):

https://dojo.telerik.com/uHEjA

I hope this is helpful.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Miguel
Top achievements
Rank 1
answered on 13 Sep 2017, 01:48 PM
Sweet, works perfectly. Thanks!
Tags
Grid
Asked by
Miguel
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Miguel
Top achievements
Rank 1
Share this question
or