Update view on long running controller action

3 posts, 1 answers
  1. Raphael
    Raphael avatar
    10 posts
    Member since:
    Feb 2013

    Posted 26 Oct Link to this post

    Hello,

    in my ASP.NET MVC application I have a Kendo Button that is calling a controller action. While this action is working I'm showing a Kendo progress control. The controller action is a long running action that is updating several database items. In addition to my current solution I'm searching for a solution to show the progress of the long running action (e.g. display "Updated x of y items").

    This is extract of my current solution:

    View:

            @(Html.Kendo().Button()
                  .Name("updateItems")
                  .Content("Update items")
                  .Events(events => events.Click("onClickUpdateItems")))
     
    <script>
        function onClickUpdateItems() {
            kendo.ui.progress($("#content"), true);
            var items = getAllItems();
            $.ajax({
                    type: "POST",
                    url: "@Url.Action("UpdateItems", "Item")",
                    data: JSON.stringify({
                        items: items
                    }),
                    contentType: "application/json"
                })
            kendo.ui.progress($("#content"), false);
    </script>

     

    In the corresponding controller action I iterate over all passed items. While the action is running I want to show the user how many items have been processed. Is there any possibility to realise this?

    Regards

    Raphael

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    226 posts

    Posted 30 Oct Link to this post

    Hello Raphael,

    I would suggest you to try and update every item in the collection with a separate ajax request. This way, you will be able to return a message after each successful update from the controller (JSON) and then use the ajax success callback to notify the user with this message (In this case "Updated x of y items"). After the last request response is received, the kendo loader can be disabled in its success callback. 


    Regards,
    Dimitar
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Raphael
    Raphael avatar
    10 posts
    Member since:
    Feb 2013

    Posted 07 Nov in reply to Dimitar Link to this post

    Hello Dimitar,

    I've change my application and your approach is working well.

    Thank you for your help!

    Regards

    Raphael

Back to Top