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

Custom DataSource

Telerik UI for ASP.NET MVC enables you to use the CustomDataSource builder that is available to helpers that support Data Binding.

The CustomDataSource builder class allows full control over the DataSource client-side API options, through Razor syntax. The CustomDataSource builder facilitates the usage of the Telerik UI helpers—for example, the helpers generate validation attributes, editors, and so on, while they utilize the flexibility of JavaScript. The CustomDataSource builder can also be used in more advanced scenarios where the regular DataSource builders prevent you from fully customizing the options of the DataSource.

DataSource and Custom DataSource

The regular DataSource builders have many settings that are configured by default. The CustomDataSource builder removes these predefined settings, so when you declare a DataSource as custom, configure these additional settings.

The following two examples demonstrate a regular ListView AjaxDataSourceBuilder and a CustomDataSource builder.

  @(Html.Kendo().ListView<Kendo.Mvc.Examples.Models.ProductViewModel>()
    .Name("listView")
    .TagName("div")
    .ClientTemplateId("template")
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Products_Read", "ListView"))
        .PageSize(21)
      )
    .Pageable()
    )

The following example demonstrates a CustomDataSourceBuilder definition.

@(Html.Kendo().ListView<Kendo.Mvc.Examples.Models.ProductViewModel>()
    .Name("listView")
    .TagName("div")
    .ClientTemplateId("template")
    .DataSource(dataSource => dataSource
        .Custom()
        .Schema(schema => schema
           .Model(model => model.Id("ProductID")))
        .PageSize(4)
        .Transport(transport => transport
            .Read(read => read.Action("Products_Read", "ListView"))
        )
    )
    .Pageable()
)

See Also

In this article