mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-07-08 18:16:08 +00:00
42 lines
1.3 KiB
Plaintext
42 lines
1.3 KiB
Plaintext
@using System.Collections
|
|
@using RadzenBlazorDemos.Data
|
|
@using RadzenBlazorDemos.Models.Northwind
|
|
@using Microsoft.EntityFrameworkCore
|
|
@using System.ComponentModel.DataAnnotations
|
|
|
|
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.Center" Gap="0.5rem" class="rz-p-sm-12">
|
|
<RadzenLabel Text="Select Value" Component="DropDownCustomObjects" />
|
|
<RadzenDropDown Data=@data TValue="MyObject" @bind-Value=@singleValue
|
|
AllowClear="true" AllowFiltering="true" Style="width: 100%; max-width: 400px;" Name="DropDownCustomObjects">
|
|
</RadzenDropDown>
|
|
</RadzenStack>
|
|
|
|
@code {
|
|
|
|
class MyObject
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
|
|
public override bool Equals(object o)
|
|
{
|
|
var other = o as MyObject;
|
|
|
|
return other?.Id == Id;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"Id: {Id}, Name: {Name}";
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return base.GetHashCode();
|
|
}
|
|
}
|
|
|
|
MyObject singleValue = new MyObject() { Id = 5, Name = "Name5" };
|
|
IEnumerable<MyObject> data = Enumerable.Range(0, 100).Select(i => new MyObject() { Id = i, Name = $"Name{i}" });
|
|
}
|