Handling 404 with noRecords template?

3 posts, 1 answers
  1. Miguel
    Miguel avatar
    22 posts
    Member since:
    Oct 2013

    Posted 11 Sep 2017 Link to this post

    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. Answer
    Stefan avatar
    3072 posts

    Posted 13 Sep 2017 Link to this post

    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:


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


    I hope this is helpful.

    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.
  3. Miguel
    Miguel avatar
    22 posts
    Member since:
    Oct 2013

    Posted 13 Sep 2017 in reply to Stefan Link to this post

    Sweet, works perfectly. Thanks!
Back to Top