<style>
. . .
/* Dialog styles */
.e-dialog {
z-index: 1001;
position: relative;
}
.e-dialog .e-dlg-header-content {
border: 0;
}
/* END dialog styles */
. . .
</style> |
<SfDialog @ref="DialogObj" Visible=@(SelectedDialog == CurrentDialog) Height="500px" Width="75%" MinHeight="500px" Target="#dialog-container" ShowCloseIcon="true">
. . .
</SfDialog> |
<div id="dialog-container" class="col-10
<!-- EMC Dialog -->
<DialogComponent @ref="Dialog" CurrentDialog="@((int)toolOptions.EMC)" SelectedDialog="@((int)selectedDialog)">
. . .
</DialogComponent>
. . .
. . .
</div> |
<head>
. . .
<script src="~/jsinterop.js"></script>
</head> |
window.Dialog = {
// To set the position and height
setStyles: function (dialogId) {
var dialogElm = document.getElementById(dialogId);
dialogElm.style.position = "absolute";
document.querySelector(dialogElm.blazor__instance.target).style.height = "500px";
},
// To remove the position and height
removeStyles: function (dialogId) {
var dialog = document.getElementById(dialogId);
var dialogTarget = document.querySelector(dialog.blazor__instance.target);
var allDialog = dialogTarget.querySelectorAll('.e-dialog');
for (var i = 0; i < allDialog.length; i++) {
allDialog[i].style.removeProperty("position");
}
dialogTarget.style.removeProperty("height");
}
} |
<SfDialog @ref="DialogObj" Visible=@(SelectedDialog == CurrentDialog) Height="500px" Width="75%" Target="#dialog-container" ShowCloseIcon="true">
. . .
<DialogEvents OnOpen="@ShowDialog" Opened="@DialogOpened" OnClose="@OnDialogClose"></DialogEvents>
<DialogAnimationSettings Effect="@AnimationEffect" Duration=600 />
</SfDialog>
@code {
[Inject]
IJSRuntime JsRuntime { get; set; }
. . .
public async Task DialogOpened()
{
//To set the style for the element.
await JsRuntime.InvokeAsync<string>("Dialog.setStyles", this.DialogObj.ID);
}
public async Task OnDialogClose(BeforeCloseEventArgs args)
{
//To remove the style for the element only when closed using the close icon.
if (args.ClosedBy == "Close Icon")
{
await JsRuntime.InvokeAsync<string>("Dialog.removeStyles", this.DialogObj.ID);
}
}
} |