|
<SfComboBox @ref="comboboxObj" TValue="string" TItem="Games" Placeholder="Select a game" DataSource="@LocalData">
<ComboBoxFieldSettings Value="ID" Text="Text"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="string" TItem="Games" ValueChange="@comboboxChange"></ComboBoxEvents>
</SfComboBox>
<SfDialog @ref="dialogObj" Width="250px" ShowCloseIcon="true" Visible="false">
. . .
</SfDialog>
@code {
SfComboBox<string, Games> comboboxObj;
SfDialog dialogObj;
. . .
public void comboboxChange(ChangeEventArgs<string, Games> args)
{
if (args.Value == "Game1" || args.Value == "Game2" || args.Value == "Game3")
{
this.dialogObj.Show();
}
}
public void dialogOkFunction()
{
//Can write required functionalities
}
public void CloseDialog()
{
this.dialogObj.Hide();
}
} |
|
<SfComboBox @ref="comboboxObj" TValue="string" TItem="Games" Placeholder="Select a game" DataSource="@LocalData">
<ComboBoxFieldSettings Value="ID" Text="Text"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="string" TItem="Games" ValueChange="@comboboxChange"></ComboBoxEvents>
</SfComboBox>
<SfDialog @ref="dialogObj" Width="250px" ShowCloseIcon="true" Visible="false">
<DialogTemplates>
<Header> Dialog Header </Header>
<Content> <p>User action confirmation.</p><p>Don't show this dialog again</p></Content>
</DialogTemplates>
<DialogButtons>
<DialogButton Content="Yes" IsPrimary="true" OnClick="@dialogOkFunction" />
<DialogButton Content="No" OnClick="@CloseDialog" />
</DialogButtons>
<DialogEvents OnOpen="@DialogOnOpen"></DialogEvents>
</SfDialog>
@code {
. . .
SfDialog dialogObj;
public bool userActionResult { get; set; } = false;
. . .
public void comboboxChange(ChangeEventArgs<string, Games> args)
{
this.dialogObj.Show();
}
public void DialogOnOpen(Syncfusion.Blazor.Popups.BeforeOpenEventArgs args)
{
args.Cancel = this.userActionResult;
}
public void dialogOkFunction()
{
//Can write required functionalities
this.userActionResult = true;
this.dialogObj.Hide();
}
public void CloseDialog()
{
this.userActionResult = false;
this.dialogObj.Hide();
}
} |
|
<SfComboBox @ref="comboboxObj" TValue="string" TItem="Games" Placeholder="Select a game" DataSource="@LocalData">
<ComboBoxFieldSettings Value="ID" Text="Text"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="string" TItem="Games" Opened="@PopupOpen" ValueChange="@comboboxChange"></ComboBoxEvents>
</SfComboBox>
<SfDialog @ref="dialogObj" Width="250px" Visible="false">
. . .
<DialogButtons>
<DialogButton Content="Yes" IsPrimary="true" OnClick="@dialogOkFunction" />
<DialogButton Content="No" OnClick="@CloseDialog" />
</DialogButtons>
</SfDialog>
@code {
SfComboBox<string, Games> comboboxObj;
SfDialog dialogObj;
public string CurrentValue { get; set; }
public string dialogContent { get; set; }
. . .
public void PopupOpen(PopupEventArgs args)
{
//To store the current combo box value before the user selects any value.
this.CurrentValue = this.comboboxObj.Value;
}
public void comboboxChange(ChangeEventArgs<string, Games> args)
{
// To check condition if the value selected is not the same value.
if (args.Value != this.CurrentValue)
{
this.dialogContent = "Are you sure you want to select the value: " + args.ItemData.Text;
this.dialogObj.Show();
}
}
public void dialogOkFunction()
{
this.dialogObj.Hide();
}
public void CloseDialog()
{
// The previous value is restored as the no button is clicked.
this.comboboxObj.Value = this.CurrentValue;
this.dialogObj.Hide();
}
} |
|
<SfComboBox @ref="comboboxObj" TValue="string" TItem="Games" Placeholder="Select a game" DataSource="@LocalData">
<ComboBoxFieldSettings Value="ID" Text="Text"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="string" TItem="Games" OnValueSelect="onSelect" Closed="onClose"></ComboBoxEvents>
</SfComboBox> |
|
public async Task onSelect(SelectEventArgs<Games> args)
{
confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure"); // Alert
if (!confirmed)
{
args.Cancel = true;
}
} |
Can I use SfDialog like JsRuntime.InvokeAsync "confirm" dialog?
confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure"); // Alert
I would like to use SfDialog Yes or No to wait process