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

Choosing Between Local and Remote Data Binding in the Grid

Environment

Product Version 2024.2.514
Product Telerik UI for ASP.NET Core Grid

Description

How can I configure the Telerik UI for ASP.NET Core Grid for local or remote data binding?

When developing a project with the Grid component, it is essential to understand the differences between local and remote data binding to choose the appropriate method for your project. This article also answers the following questions:

  • What is local data binding, and how does it work with the Grid?
  • What is remote data binding, and how does it enhance the Grid functionality?
  • How do I decide which data binding method to use for Grid in my ASP.NET Core application?

Solution

Local Data Binding is a method where data is provided to the Grid from the Controller to the View at the initial load. This approach is efficient for small datasets that do not require server-side operations like paging, sorting, or filtering after the initial load.

Example of Local Data Binding:

public ActionResult Local_Data_Binding()
{
    var model = productService.Read();
    return View(model);
}

In the View:

@model IEnumerable<Kendo.Mvc.Examples.Models.ProductViewModel>
@using Kendo.Mvc.UI

@(Html.Kendo().Grid(Model))

Local Data Binding is demonstrated here.

Remote Data Binding, in contrast, utilizes AJAX requests to perform server-side operations. This method is suitable for handling large datasets and supports dynamic operations like paging, filtering, sorting, and editing directly on the server, thus reducing the initial load on the client side.

It is important to note that using the .ServerOperation() property Remote binding can function like Local binding:

Example of Remote Data Binding:

public IActionResult Customers_Read([DataSourceRequest] DataSourceRequest request)
{
    return Json(GetCustomers().ToDataSourceResult(request));
}

In the Grid configuration:

.DataSource(dataSource => dataSource
    .Ajax()
    .PageSize(20)
    .ServerOperation(false)
    .Read(read => read.Action("Orders_Read", "Grid"))
)

Remote Data Binding is showcased here.

Decision Criteria

As a verdict, I would highly recommend you to use Remote Data Binding because it supports complex features like Editing without compromising performance.

More ASP.NET Core Grid Resources

See Also

In this article