New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Events

You can subscribe to the available DataSource events and further customize the behavior of the DataSource.

Handling by Handler Name

The following example demonstrates how to subscribe to events by a handler name.

   @(Html.Kendo().DataSource<ProductViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
            .Events(ev => ev.RequestStart("onRequestStart"))
            .Read(read => read.Action("Products_Read", "DataSource"))
            ... // Additional configuration
        )
    )

    <script>
        function onRequestStart(e){
            // Handle the RequestStart event that triggers the DataSource makes a request to the remote service.
        }
    </script>

Handling by Template Delegate

The following example demonstrates how to subscribe to events by a template delegate.

   @(Html.Kendo().DataSource<ProductViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
            .Read(read => read.Action("Products_Read", "DataSource"))
            .Events(e => e.RequestStart(@<text>
                function() {
                    // Handle the RequestStart event inline.
                }
                </text>)
            )
            ... // Additional configuration
        )
    )

See Also

In this article