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

Cancel DataBinding on Error

2 Answers 136 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ruairi
Top achievements
Rank 1
Ruairi asked on 28 Jul 2014, 03:33 PM
I'm using the MVC TreeView and I'm binding to a datasource as below:

@(Html.Kendo().TreeView()
        .Name("tvDocumentDirs")
        .DataTextField("Name")
        .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
          .Select("tvDocumentDirs_onSelect")
          .Change("tvDocumentDirs_onChange")
        )
    )


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 Answers, 1 is accepted

Sort by
0
Ruairi
Top achievements
Rank 1
answered on 28 Jul 2014, 04:01 PM
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.
0
Accepted
Petur Subev
Telerik team
answered on 30 Jul 2014, 01:39 PM
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.

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

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

Kind Regards,
Petur Subev
Telerik
 

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.

 
Tags
TreeView
Asked by
Ruairi
Top achievements
Rank 1
Answers by
Ruairi
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or