I'm currently trying to make some components to speed up my form creation.
My first one was to be for dropdowns
<DropDownInput Name="ClientId" Label="Client"
@bind-Value="@RefItem.ClientId" Data="@ClientList"
Disabled="true" />
Custom DropDownInput.razor
@inherits RadzenDropDown<IEnumerable<DropDownList>>
<div class="col-md-4 align-items-center d-flex">
<RadzenLabel Text="@Label" />
</div>
<div class="col-md-8">
<RadzenDropDown Name="@Name" Data="@Data" Disabled="@Disabled"
TextProperty="Name" ValueProperty="Id" style="width: 100%;" />
</div>
@code {
[Parameter]
public string Label { get; set; }
}
I know I must be missing something simple here but it I'm sure why its failing to build
enchev
August 17, 2022, 3:59pm
2
You must specify either @bind-Value or TValue for the DropDown.
Check our demos for reference.
I'm revisiting this I had given up last time, But a new utility for this has come up and I'm hoping to figure out what I'm missing.
RadzenDropDownFormField.razor
@using Radzen
@using TenDSecurity.Domain.InputModels
@inherits RadzenDropDown<TValue>
@typeparam TValue
<RadzenFormField Text=@FormFieldText Style="width: 100%;">
<RadzenDropDown style=@DropDownStyle class=@DropDownClass
Name="@Name" TValue="TValue" Change=@Change Data=@DropDownList
TextProperty="Name" ValueProperty="Id" Disabled="@Disabled" ReadOnly="@ReadOnly" />
</RadzenFormField>
@code {
[Parameter]
public IReadOnlyList<DropDownList> DropDownList { get; set; }
[Parameter]
public string DropDownClass { get; set; } = "w-100";
[Parameter]
public string DropDownStyle { get; set; } = "display: block";
[Parameter]
public string FormFieldText { get; set; } = "Outlined/Default";
}
On my TestingBlazor.Razor Page its called with this
I removed My
@if (salesRepList is not null)
{
<RadzenDropdownFormField Data="salesRepList" @bind-Value=@model.SalesRepId />
}
@code
protected override void OnInitialized()
{
salesRepList = new List<DropDownList>
{
new()
{
Id = 1,
Name = "John Doe"
},
new()
{
Id = 2,
Name = "Jane Smith"
}
};
}
void HitThis()
{
var RepName = salesRepList.FirstOrDefault(x => x.Id == model.SalesRepId).Name;
ShowNotification(new NotificationMessage
{
Severity = NotificationSeverity.Success,
Summary = "Success!",
Detail = $"Success Detail You Selected {RepName}",
Duration = 4000
});
}
Buy Sadly I'm getting a strange error on Page load that does really point me in the right direction
We haven't seen this error before and don't know what could cause it. It looks as if the JavaScript function cannot find an element. You can use the JavaScript debugger of your browser to see what the problem is.