I have used Tab control for page navigation.I have set "showclosebutton=true" in tab control.I would like to know how to show confirmation message when I close tab item.
Note:-
Confirmation message should show when there is some changes in tab component
|
<SfTab @ref="TabObj" ShowCloseButton="true">
<TabEvents Removing="OnRemoving"></TabEvents>
<TabItems>
. . .
</TabItems>
</SfTab>
@if (IsVisible)
{
<SfDialog @ref="ConfirmationDialog" Width=250 Target=".BlazorTab" IsModal=true @bind-Visible="@ConfirmDlgVisible">
<DialogTemplates>
<Header><div>Delete Tab item</div></Header>
<Content><div>Do you want to remove this item?</div></Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Yes" IsPrimary="true" OnClick="@RemoveTabItem" />
<DialogButton Content="No" OnClick="@OnSubmit"></DialogButton>
</DialogButtons>
</SfDialog>
}
@code{
SfDialog ConfirmationDialog;
SfTab TabObj;
public bool IsVisible { get; set; } = true;
private bool ConfirmDlgVisible { get; set; } = false;
private bool flag { get; set; } = true;
private int removingIndex;
public void RemoveTabItem()
{
@*If User pressed Yes in confirm dialog the tab item will be removed*@
TabObj.RemoveTab(removingIndex);
flag = true;
this.OnSubmit();
}
public void OnSubmit()
{
flag = true;
@*If User pressed No in confirm dialog the dialog window will be closed*@
ConfirmDlgVisible = false;
}
public void OnRemoving(Syncfusion.Blazor.Navigations.RemoveEventArgs args)
{
removingIndex = args.RemovedIndex;
if (flag && IsVisible)
{
@*Prevent the tab item from removing*@
args.Cancel = true;
@*Opening the confirm dialog*@
ConfirmDlgVisible = true;
flag = false;
}
}
} |
Thanks for quick support...
I need to show " SfDialog" when there is change in "Tab" component (Select Value from dropdown or enter value in textbox etc)
|
<SfTab @ref="TabObj" ShowCloseButton="true">
<TabEvents Removing="OnRemoving"></TabEvents> <TabItems> <TabItem> <ChildContent> <TabHeader Text="Dropdown"></TabHeader> </ChildContent> <ContentTemplate> <SfDropDownList TValue="AnimationEffect" DataSource="@AnimationData" TItem="Effect" @bind-Value="PreviousEffect"> <DropDownListEvents ValueChange="PreviousChange" TValue="AnimationEffect" TItem="Effect"></DropDownListEvents> <DropDownListFieldSettings Value="ID" Text="Text"></DropDownListFieldSettings> </SfDropDownList> </ContentTemplate> </TabItem> </TabItems> </SfTab> @code{ public void PreviousChange(Syncfusion.Blazor.DropDowns.ChangeEventArgs<AnimationEffect, Effect> args)
{ if (IsVisible) { @*Opening the confirm dialog*@ ConfirmDlgVisible = true; } } } |