Custom callback and Error Handling for Destroy in ImageBrowser

2 posts, 0 answers
  1. Ramoji
    Ramoji avatar
    3 posts
    Member since:
    Nov 2012

    Posted 17 Jan 2014 Link to this post

    Hi Team,

    I am using ImageBrowser as a part of editor widget in my screen . I need to delete an image only if it is not used by other resources. I wired the destroy to an action that checks whether its in use or not. If its in use I would return a message saying it could not be deleted .I got stuck on how to return this message to destroy and stop it from deleting the image from the library.
    As the documentation says the configuration values will be sent to jquery.Ajax() function I tried using the success and error functions in the destroy configuration but could not handle the request. It always shows up as undefined.This is how I configured my imagebrowser.

    01.imageBrowser: {
    02.           path: "/BroadcastType/",
    03.           transport: {
    04.                read: {
    05.                    url: function () { $(".k-breadcrumbs.k-textbox").css('display', 'none'); return "../ImageBrowser/Read" },
    06.                    type: "POST"
    07.                },
    08.                destroy: {
    09.                    url: "../ImageBrowser/Destroy",
    10.                    type: "POST" ,
    11.                    success:function(){},
    12.                   error:function(){}
    13.                },
    14.                thumbnailUrl: "../ImageBrowser/Thumbnail",
    15.                uploadUrl: "../ImageBrowser/Upload",
    16.                imageUrl: "../ImageBrowser/Image?name={0}"
    17.            }
    18.        }
    In short,
    How to stop image from being destroyed from the library until I get a response from backend?
    How to handle any errors while backend execution?
    Can we override the callback functions in the destroy configuration or should we deal with them at the transport level?

    Any pointer to the right direction will be appreciated .

    Thanks,
    Ramoji.




  2. Dimo
    Admin
    Dimo avatar
    8333 posts

    Posted 21 Jan 2014 Link to this post

    Hello Ramoji,

    Please avoid posting duplicate forum threads and support tickets.

    ===

    The DataSouce transport and its CRUD request types do not have success and error callbacks. The Kendo UI DataSouce itself has an error event, which the ImageBrowser widget uses internally. In your case you can throw an HTTP Exception in the Destroy action method. The ImageBrowser will display the custom error message automatically.

    http://msdn.microsoft.com/en-us/library/bazc3hww(v=vs.110).aspx

    An alternative, but more complex approach would be to configure the destroy property of the Transport as a custom function, which will allow you to handle the custom request's success and error events:

    http://docs.kendoui.com/api/framework/datasource#configuration-transport.destroy


    Regards,
    Dimo
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top