|
<div id="combobox">
<SfComboBox ID="DeviceTypeEntryId" AllowFiltering="true" TValue="int?" TItem="DeviceType" Placeholder="Select a customer" DataSource="@DeviceTypes">
<ComboBoxTemplates TItem="DeviceType">
<ItemTemplate>
<span><span class='name'>@((context as DeviceType).DeviceModel)</span><span class='country'>@((context as DeviceType).DeviceColor)</span></span>
</ItemTemplate>
</ComboBoxTemplates>
<ComboBoxFieldSettings Text="DeviceModel" Value="Id"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="int?" ValueChange="ValueChangeHandler"></ComboBoxEvents>
</SfComboBox>
</div>
<div id="textbox">
<SfTextBox @bind-Value="@DeviceColor"></SfTextBox>
</div>
@code {
public string DeviceColor { get; set; }
public class DeviceType
{
public int Id { get; set; }
public string DeviceModel { get; set; }
public string DeviceColor { get; set; }
}
List<DeviceType> DeviceTypes = new List<DeviceType>
{
new DeviceType() { DeviceModel = "Redmi", DeviceColor = "Red", Id = 1 },
new DeviceType() { DeviceModel = "Sony", DeviceColor = "Blue", Id = 2 },
new DeviceType() { DeviceModel = "Samsung", DeviceColor = "Green", Id = 3 },
new DeviceType() { DeviceModel = "Micromax", DeviceColor = "Orange", Id = 4},
};
public void ValueChangeHandler(Syncfusion.Blazor.DropDowns.ChangeEventArgs<int?> args)
{
var item = JsonConvert.DeserializeObject<DeviceType>(args.ItemData.ToString());
this.DeviceColor = item.DeviceColor;
}
} |
|
|
|
<SfButton @onclick="@OnClicked">Open Modal Dialog</SfButton>
<SfDialog @bind-Visible="@IsVisible" Width="350px" IsModal="true">
<DialogEvents OnOverlayClick="OnOverlayclick">
</DialogEvents>
<DialogTemplates>
<Content>
<div id="combobox">
<SfComboBox ID="DeviceTypeEntryId" AllowFiltering="true" Index="2" TValue="int?" TItem="DeviceType" Placeholder="Select a customer" DataSource="@DeviceTypes">
<ComboBoxTemplates TItem="DeviceType">
<ItemTemplate>
<span><span class='name'>@((context as DeviceType).DeviceModel)</span><span class='country'>@((context as DeviceType).DeviceColor)</span></span>
</ItemTemplate>
</ComboBoxTemplates>
<ComboBoxFieldSettings Text="DeviceModel" Value="Id"></ComboBoxFieldSettings>
<ComboBoxEvents TValue="int?" ValueChange="ValueChangeHandler"></ComboBoxEvents>
</SfComboBox>
</div>
<div id="textbox">
<SfTextBox @bind-Value="@DeviceColor"></SfTextBox>
</div>
</Content>
</DialogTemplates>
</SfDialog>
@code {
...
public string DeviceColor { get; set; } = "Green";
} |
|
SfButton @onclick="@OnClicked">Open Modal Dialog</SfButton>
<SfDialog @bind-Visible="@IsVisible" Width="350px" IsModal="true">
<DialogEvents OnOverlayClick="OnOverlayclick">
</DialogEvents>
<DialogTemplates>
<Content>
<div id="combobox">
<SfComboBox ID="DeviceTypeEntryId" AllowFiltering="true" Index="2" @bind-Value="@DeviceColor" TValue="string" TItem="DeviceType" Placeholder="Select a customer" DataSource="@DeviceTypes">
<ComboBoxTemplates TItem="DeviceType">
<ItemTemplate>
<span><span class='name'>@((context as DeviceType).DeviceModel)</span><span class='country'>@((context as DeviceType).DeviceColor)</span></span>
</ItemTemplate>
</ComboBoxTemplates>
<ComboBoxFieldSettings Text="DeviceModel" Value="DeviceColor"></ComboBoxFieldSettings>
</SfComboBox>
</div>
<div id="textbox">
<SfTextBox @bind-Value="@DeviceColor"></SfTextBox>
</div>
</Content>
</DialogTemplates>
</SfDialog>
@code {
private bool IsVisible { get; set; } = true;
public string DeviceColor { get; set; }
...
} |
|
|