4

I am using the code snippet from this link to refresh the view. It works perfectly fine.

  // Set Ajax refresh context
  var evtAjax = {
    currentCtx: ctx,
    csrAjaxRefresh: true
  };
  // Initiate Ajax Refresh on the list
  AJAXRefreshView(evtAjax, SP.UI.DialogResult.OK);

What I am looking for is a way to call showWaitScreenWithNoClose brefore and after the function AJAXRefreshView refreshes the view so that user has some visual indication that some refresh is happening. Is that possible?

3 Answers 3

1

If you look at the code used to refresh, you'll notice it uses the CLVPOnReadyStateChangeCallback function and that funtion has a check for a callback function:

    if (typeof clvp.ctx.onDataRefreshCompleted == "function") {
        callback = clvp.ctx.onDataRefreshCompleted;
        clvp.ctx.onDataRefreshCompleted = null
    }

You can then do it like this:

ctx.onDataRefreshCompleted = function() {
    waitDialog.close(); 
}

var waitDialog =  SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);

var evtAjax = {
    currentCtx: ctx,
    csrAjaxRefresh: true
  };

AJAXRefreshView(evtAjax, SP.UI.DialogResult.OK);

If you have multiple webparts you could use the g_ctxDict to get the right "ctx" based on different values, like the Title:

AJAXRefreshView({
    currentCtx: (function(ctx) { 
        var waitDialog =  SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);
        ctx.onDataRefreshCompleted = function() {
            waitDialog.close(); 
        }       
        return ctx;

    })(g_ctxDict[Object.keys(g_ctxDict).filter(function(c) { return g_ctxDict[c].ListTitle === "Tasks" })]),
    csrAjaxRefresh: true
  }, SP.UI.DialogResult.OK);
-1

To Show 'showWaitScreenWithNoClose' Dialog:

var waitDialog =  SP.UI.ModalDialog.showWaitScreenWithNoClose(SP.Res.dialogLoading15);

To Hide or Remove 'showWaitScreenWithNoClose' Dialog:

window.parent.waitDialog.close();
1
  • I know how to call the showWaitScreenWithNoClose method. But how do I know that the view is refreshed after call to AJAXRefreshView which is an asynchronous event.
    – Naveen
    Commented Dec 1, 2016 at 9:33
-1

You can use setTimeout method to display the processing.

// Set Ajax refresh context
  var evtAjax = {
    currentCtx: ctx,
    csrAjaxRefresh: true
  };
  // Initiate Ajax Refresh on the list
  setTimeout(showWaitScreenWithNoClose(), 3000);
  AJAXRefreshView(evtAjax, SP.UI.DialogResult.OK);
  setTimeout(showWaitScreenWithNoClose(), 3000);

I know it's not a good solution but It will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.