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

Update view on long running controller action

2 Answers 81 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Raphael
Top achievements
Rank 1
Raphael asked on 26 Oct 2017, 08:11 AM

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

Sort by
0
Accepted
Dimitar
Telerik team
answered on 30 Oct 2017, 07:06 AM
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.
0
Raphael
Top achievements
Rank 1
answered on 07 Nov 2017, 08:28 AM

Hello Dimitar,

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

Thank you for your help!

Regards

Raphael

Tags
General Discussions
Asked by
Raphael
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Raphael
Top achievements
Rank 1
Share this question
or