Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
149583 | Dec 2,2019 10:01 AM UTC | Jun 2,2020 07:04 AM UTC | Blazor | 7 |
![]() |
Tags: ListBox |
@inherits EjsListBox<int[]>
<EjsListBox CssClass="e-custom-font" TValue="int[]" DataSource="DataSource" @bind-Value="@_bindValue" EnableRtl="true" Height="Height">
<ListBoxEvents TValue="int[]" ValueChange="ValueChangedHandler"></ListBoxEvents>
<ListBoxFieldSettings Text="Name" Value="Id" />
<ListBoxSelectionSettings ShowCheckbox="true"></ListBoxSelectionSettings>
</EjsListBox>
@code {
private int[] _bindValue { get; set; }
[Parameter]
public int[] bindValue
{
get => _bindValue;
set
{
this._bindValue = value;
}
}
[Parameter]
public EventCallback<int[]> bindValueChanged { get; set; }
public void ValueChangedHandler()
{
this.bindValueChanged.InvokeAsync(_bindValue); // Invoke EventCallback to update your model property
}
}
|
<ListBoxComponent DataSource="DataSource" @bind-bindValue="@Value" Height="340">
</ListBoxComponent>
<span>selected count: </span> @Value.Count() |
[Parameter]
public EventCallback<ListBoxChangeEventArgs> ListBoxValueChanged { get; set; } // Custom EventCallback
public void ValueChangedHandler(ListBoxChangeEventArgs args)
{
this.ListBoxValueChanged.InvokeAsync(args); // Invoke the Custom EventCallback
} |
<ListBoxComponent DataSource="DataSource" @bind-bindValue="@Value" Height="340" ListBoxValueChanged="ListBoxValueChangedHandler">
</ListBoxComponent>
@code{
public void ListBoxValueChangedHandler(ListBoxChangeEventArgs args)
{
Console.WriteLine(args);
}
} |
how to implement TwoWay Databinding in custum component using Listbox***************ListBoxComponent**************@if (IsMultiSelect){}else{@{NameIdGroup currentData = Context as NameIdGroup;if (!String.IsNullOrEmpty(currentData.Description)){@currentData.Description}}}@code{private int[] _bindValue { get; set; }[Parameter]public int[] bindValue{get => _bindValue;set{if (_bindValue == value) return;_bindValue = value;BindingValueChanged.InvokeAsync(value);}}[Parameter]public EventCallbackBindingValueChanged { get; set; } [Parameter]public IListDataSource { get; set; } = null; ****************use ListBoxComponent*************************@bind-bindValue="MainModel.Diseases" Header="@LabelValues.Diseases.QuestionLabel" Height="320px">
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.