Cancel DataBinding on Error

3 posts, 1 answers
  1. Tyler
    Tyler avatar
    53 posts
    Member since:
    Nov 2013

    Posted 28 Jul 2014 Link to this post

    I'm using the MVC TreeView and I'm binding to a datasource as below:

            .DataSource(dataSource => dataSource
                .Model(m => m.Id("Path").HasChildren("HasChildren"))
                .Read("ReadDirectoryGetDirs", "Documents").Events(e=>e.RequestEnd("tvDocumentDirs_onRequestEnd").Error("tvDocumentDirs_onError"))
            .Events(events => events

    The .Read("ReadDirectoryGetDirs", "Documents") - everything works fine. However in the controller action if any error occurs the TreeView hangs (waits indefinitely) what I want to do is handle any errors in the controller action return the error to page, handle the error and then cancel the databind on the treeview. Is it possible to cancel the databind for the treeview?
  2. Tyler
    Tyler avatar
    53 posts
    Member since:
    Nov 2013

    Posted 28 Jul 2014 in reply to Tyler Link to this post

    I've been able to handle this by throwing an HttpException error from the controller e.g.
    throw new HttpException(403, "Access denied");

    What happens now is the TreeView has following text 'Request failed' followed by a Retry button.
  3. Answer
    Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 30 Jul 2014 Link to this post

    Hello Tyler,

    The DataSource uses the error event of the DataSource internally to show the retry button that you mentioned there is no way to turn off that button and the built-in error handler. You can use the error event of the dataSource in case you want to fully re-bind the TreeView or to manually remove that node which failed to load.

    I am sorry for any inconvenience caused. Let me know if I can be of any further assistance.

    Kind Regards,
    Petur Subev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top