Events
The Telerik UI ListView for ASP.NET Core exposes a number of JavaScript events that allow you to control the behavior of the UI component.
For a complete example of how to handle all ListView events triggered by user interaction, refer to the demo on using the events of the ListView .
Subscribing to Events
The following example demonstrates how to subscribe to the DataBound event.
@(Html.Kendo().ListView<Kendo.Mvc.Examples.Models.ProductViewModel>()
.Name("listView")
.TagName("ul")
.ClientTemplateId("template")
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Products_Read", "ListView"))
.PageSize(21)
)
.Pageable(pageable => pageable
.Refresh(true)
.ButtonCount(5)
.PageSizes(new[] { 5, 15, 21 })
)
.Events(e=>e.DataBound("onDataBound"))
)Get the Data Item in the DataBound Handler
You can register the DataBound handler in the ListView HtmlHelper with .Events(e => e.DataBound("onListViewDataBound")). The event does not pass a specific data item ID. Use e.sender to access the ListView, then call dataItem() for each rendered item to read its fields.
function onListViewDataBound(e) {
var listView = e.sender;
listView.items().each(function () {
var dataItem = listView.dataItem(this);
console.log(dataItem.ProductID);
});
}
Replace ProductID with the ID field in your data item. You can also read other fields from dataItem and pass them to your tooltip initialization logic.