Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am calling a controller method from an awesome grid as mentioned below.

@(Html.Awe().Grid(documentGridId)
       // .Mod(o => o.Custom("gridLoading1").ColumnsSelector())
        .Url(Url.Action("GridGetItems", "Document"))
        .Parameter("DocumentFolder", Model.Item1)
        .Parameter("DocumentParent", Model.Item2)
        .Parent("connID", "p1")
        .Resizable(true)
        .Height(200)
        .ColumnWidth(120)
        .PageSize(25)
        .Groupable(false)
        .Columns(
            columns.ToArray()
        )
)

And in controller method I have called Functions.SendProgress() to get the progress bar. Once displayed its not going away. What has to be called from the controller so that the progress bar goes away after 100% completion.
 public ActionResult GridGetItems(GridParams g, string parent, string DocumentFolder, string p1, string DocumentParent, bool? restore)
        {
Functions.SendProgress("Loading Files", 10, 100, p1);

//Method code continues

Functions.SendProgress("Loading Files", 100, 100, p1);

   return Json(model);
        }

Please let me know. Help needed urgently :(.

What I have tried:

Tried calling
function ProgressBarModal(showHide) {
    debugger;
    if (showHide === 'show') {
        $('#mod-progress').modal('show');
        if (arguments.length >= 2) {
            $('#progressBarParagraph').text(arguments[1]);
        } 

        window.progressBarActive = true;

    } else {
        $('#mod-progress').modal('hide');
        window.progressBarActive = false;
    }
}

after grid is loaded. But its not the correct way since we don't have any way to determine whether the grid is loaded or not.

I have to call some method from the controller method itself to hide the progress bar. Please help.
Posted
Updated 19-Jan-17 22:52pm
v2

1 solution

If i am not wrong then you must be using this grid.
this grid has Events property. so you can run your own javascript when event occurs.
you can use
.on('item:stacked', [function])
event to increment your progress counter, and
.on('grid:done', [function])
to finish the progress complete.
I hope this helps.

no need to write any code on controller for showing the loading.
and for showing loader i would recommend you to go for NProgress
 
Share this answer
 
Comments
Member 12958722 20-Jan-17 8:43am    
I can't change the awesome grid scripts since we have used this in the entire application. Do you have any idea how to include Javascript code in C# controller method.

SO, if I include these line
$('#mod-progress').modal('hide');
window.progressBarActive = false;

The progress bar gets hidden.
sachin.vishwa90 20-Jan-17 10:48am    
you don't need to change the awesome grid script, in fact, you have to use the functionality given by awesome grid. this change will be on the view only. you can never show the progress from controller until and unless you are hitting the controller action again and again to update the view.
Member 12958722 20-Jan-17 11:26am    
ok thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900