|
@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
Everything was working fine. At times, I updated components. Since my listviews were working fine in my app, I did not have to debug those. I happened to notice while debugging another page, that my page with ListView which was working in debug as well, stopped populating ItemData of the click event's arg. It still works as expected if I run it without debugging while "DEBUG" mode chosen and it also works in Release mode.
I find it strange that my listview's ItemData in the Click event works fine in "Release" mode. In "Debug" mode, if I run it without debugging, it works but while debugging, the ItemData of OnListItemClicked(ClickEventArgs<DataModel> args) which is triggered on Click, is null.
I created a new app to share but I can't reproduce it in the new app. Unfortunately, I don't have anything that I can share. A new page in my app with the same code that I used for the new app, also has the same issue in my app but not in the new app.
-- update 2025-08-31
I recreated the solution and added the same projects to it. This fixed whatever was broken. Not a ListView problem.
Thanks
Harshad
Hi Harshad,
We understand you’re experiencing a problem where the ItemData in the OnListItemClicked event of your ListView is null when debugging in Debug mode, but it works correctly in Release mode or when running Debug mode without a debugger included.
After investigating similar reports, we found that this issue can sometimes occur due to project configuration or build settings, rather than a problem with the ListView component itself. In one case, recreating the solution and re-adding the projects resolved the issue, suggesting a possible corruption in the solution file or mismatched build settings.
If you are still having issues with our component, please provide a minimal reproducible sample along with additional details about your issue in the form of video footage, it will help us assist you more effectively in finding a solution. Your input will be invaluable in helping us understand your issue and provide a timely resolution.
Leo Lavanya Dhanaraj
Hi Dhanaraj,
Thank you for your response. It is exactly right! I also removed and re-added the projects and it worked. I had updated my earlier post to this effect.
Thank you for your continued support.
Regards
Harshad
We are glad to know that your issue has been resolved. Please get back to us if you need any further assistance in the future.