Hello, I am trying to open a dialog for the user to submit something. After this submit, some work is done and the dialog should close and then the datagrid should refresh. I have a button with this code:
await Task.Yield();
// Refresh the grid if something changed.
if (ret == true)
{
_selectedDocuments = null;
await Task.Yield();
await _grid.RefreshDataAsync();
}
}
This opens up a modal where a user can submit, on submit I do some work like so:
// Open the "saving" dialog before doing the work.
dynamic ret = _dialogService.OpenAsync("",
new Dictionary<string, object>() { { "Message", GetPostSpinnerMessage(FormFunction.Edit) } },
Constants.Web.MODAL_OPTIONS_SPINNER);
//await some db work
_dialogService.Close(); // Close the "saving" dialog
_dialogService.Close(true);
My issue is the datagrid is refreshing in the background and then the dialog closes. I need it to close first and then the datagrid to refresh. Weirdly enough it works fine on the initial startup but any subsequent calls to this method have the odd behavior. Any clues as to what is going on here? Thanks for any help!
I've had issues like this caused by click propagation. Check your debugger during submit to see if more than one dialog is opened. Fix it by adding @onclick:stopPropagation="true" to your button.
@SloSuenos Thanks for the suggestion, but it didn't seem to affect the issue. I do open an initial dialog which allows the user to submit something, then I open a second dialog on submit to show a loading image. Which is why I call dialogService.Close() twice. The loading dialog always manages to close properly, it's the initial one that doesn't.
@mumfie I just want to show a dialog after a button is pressed within another dialog and close them properly. This seems possible from what I have seen but the timing seems weird. My issue is similar to:
Except I am not using OnClose event.
After I call this in my dialog page, it should close the savings dialog(which it does) but also the original dialog. It does return true properly which I use below:
I just don't understand why it is returning true but the dialog still hasn't closed? I would expect it to close and then for my statement to be hit. This is what causes the datagrid to refresh before the dialog closes.
@mumfie I'm not sure what is going on then. This seems to work fine for me on the first time I submit. But if I do it again, it does stay open until the grid is done refreshing. If I step through it works fine, but when I don't use breakpoints and let it go at its own speed, the timing issue appears again. I know it has to do with the async nature of these components but I'm not sure how.