@using Syncfusion.Blazor.Lists
<SfListView @ref="listview" DataSource="@DataSource" >
<ListViewEvents TValue="DataModel" Clicked="Click"></ListViewEvents>
<ListViewTemplates TValue="DataModel">
<Template>
<span class="e-list-item-header">@((context as DataModel).Text)</span>
</Template>
</ListViewTemplates>
<ListViewFieldSettings TValue="DataModel" Id="Id" Text="Text"></ListViewFieldSettings>
</SfListView>
@code {
SfListView<DataModel> listview;
public string HeaderTitle = "Listview";
List<DataModel> DataSource = new List<DataModel>()
{
new DataModel { Id = "1", Text = "1", Type = "Odd"},
new DataModel { Id = "2", Text = "2", Type = "Even"},
new DataModel{ Id = "3", Text = "3", Type = "Odd"},
new DataModel{ Id = "4", Text = "4", Type = "Even"},
};
public class DataModel
{
public string Id { get; set; }
public string Text { get; set; }
public string Type { get; set; }
}
public void Click(ClickEventArgs<DataModel> args)
{
var clicked_list = args.ItemData;
}
} |
@using Syncfusion.Blazor.Lists
<SfListView @ref="listview" DataSource="@DataSource" ShowHeader="true">
<ListViewEvents TValue="CompanyDataModel" Clicked="Click"></ListViewEvents>
<ListViewTemplates TValue="CompanyDataModel">
<Template>
<span class="e-list-item-header">@((context as CompanyDataModel).name)</span>
</Template>
</ListViewTemplates>
<ListViewFieldSettings TValue="CompanyDataModel" Id="id" Text="name" GroupBy="group"></ListViewFieldSettings>
</SfListView>
@code {
SfListView<CompanyDataModel> listview;
public string HeaderTitle = "Listview";
List<CompanyDataModel> DataSource = new List<CompanyDataModel>()
{
new CompanyDataModel { id = "1", name = "1", group = "Odd"},
new CompanyDataModel { id = "2", name = "2", group = "Even"},
new CompanyDataModel{ id = "3", name = "3", group = "Odd"},
new CompanyDataModel{ id = "4", name = "4", group = "Even"},
};
public class CompanyDataModel
{
public string id { get; set; }
public string name { get; set; }
public string group { get; set; }
}
public void Click(ClickEventArgs<CompanyDataModel> args)
{
var clicked_list = args.ItemData;
}
}
|
It helps me.I want to add put only setter and getter on POCO objetcs.
public class FileItem
{
public int id { get; set; } // Use get/set else ListViewEvents/Clicked returns null
public string name { get; set; }
public Geideon.FileInfo fileRef; // Don't use get/set else get json serialisation error
}
Hello,
Sorry to reopen this thread but, i'm getting same issue with empty data after clicked event
I'm using .Net 9 and Sync version 28.1.33
I have verified that the properties has de get/set stuff
Many thanks for your support
Regards
Hi Angel,
We have checked the Clicked event issue with the Blazor ListView component in the reported version(28.1.33) and framework(.NET 9). However, we were unable to replicate the issue on our end. We tested this issue in different browsers, both during the initial rendering and after interacting with the component, and we received the correct list data details for the clicked item. For your reference, we have included the validated sample and an output screenshot.
|
We suggest that you check the shared sample on your end. If the issue persists, please provide the steps to replicate the issue and any relevant code snippets. This information will help us better understand your situation and provide a timely resolution.
Regards,
Leo Lavanya Dhanaraj