SfListBox not responding to clearing of DataSource
Please see the following video
https://www.screencast.com/t/EIs1Cxo7
Attached is the code and razor component page
Version 19.2.0.62 (unable to upgrade as 19.3 breaks my menus) See support ticket 347650
Attachment: Aggregate.razor_7b5466e8.zip
SIGN IN To post a reply.
3 Replies
1 reply marked as answer
GK
Gayathri KarunaiAnandam
Syncfusion Team
November 11, 2021 04:08 AM UTC
Hi Mike,
We have checked your reported query. We would like to let you know that we can use Clear method for Observable collection of ListBox. We can clear the List type items by emptying the list. Please check the below code snippet.
Index:
|
<SfListBox DataSource="@groupA" TItem="ListItem" Height="400px" TValue="string[]" @ref="listbox">
<ListBoxFieldSettings Text="Name" Value="Code"></ListBoxFieldSettings>
<ListBoxToolbarSettings Items="@items"></ListBoxToolbarSettings>
<ListBoxTemplates TItem="ListItem">
<NoRecordsTemplate>
<span>NO DATA AVAILABLE</span>
</NoRecordsTemplate>
</ListBoxTemplates>
<SfButton Content="Cancel" OnClick=@(() => CancelAggregate()) />
@code
{
public void CancelAggregate()
{
groupA = new List<ListItem> ();
}
} |
Counter:
|
<SfListBox DataSource="@Data" TValue="string[]" TItem="ListData" AllowDragAndDrop="true">
<ListBoxFieldSettings Text="text" Value="id"></ListBoxFieldSettings>
</SfListBox>
<SfButton CssClass="e-success" @onclick="PropertyBinding">Clear</SfButton>
@code
{
public ObservableCollection<ListData> Data { get; set; }
public class ListData
{
public string id { get; set; }
public string text { get; set; }
public static ObservableCollection<ListData> getListData()
{
ObservableCollection<ListData> Data = new ObservableCollection<ListData>();
Data.Add(new ListData() { text = "Hennessey Venom", id = "list-01" });
Data.Add(new ListData() { text = "Bugatti Chiron", id = "list-02" });
Data.Add(new ListData() { text = "Bugatti Veyron Super Sport", id = "list-03" });
Data.Add(new ListData() { text = "SSC Ultimate Aero", id = "list-04" });
Data.Add(new ListData() { text = "Koenigsegg CCR", id = "list-05" });
Data.Add(new ListData() { text = "McLaren F1", id = "list-06" });
Data.Add(new ListData() { text = "Aston Martin One- 77", id = "list-07" });
Data.Add(new ListData() { text = "Jaguar XJ220", id = "list-08" });
Data.Add(new ListData() { text = "McLaren P1", id = "list-09" });
Data.Add(new ListData() { text = "Ferrari LaFerrari", id = "list-10" });
return Data;
}
}
protected override void OnInitialized()
{
this.Data = ListData.getListData();
}
private void PropertyBinding()
{
this.Data.Clear();
}
}
|
For your reference, please check the below sample link.
Please check and get back to us, if you need further assistance.
Regards,
Gayathri K
Marked as answer
MC
Mike Chafin
November 11, 2021 10:59 AM UTC
Ah, that works and I understand why.
Thanks.
AS
Aravinthan Seetharaman
Syncfusion Team
November 12, 2021 05:51 AM UTC
Hi Mike,
Thanks for the update.
We are happy to hear that your issue has been resolved. Please feel free to contact us if you need any further assistance on this.
Regards,
Aravinthan S
SIGN IN To post a reply.
- 3 Replies
- 3 Participants
- Marked answer
-
MC Mike Chafin
- Nov 9, 2021 03:27 PM UTC
- Nov 12, 2021 05:51 AM UTC