This is a migrated thread and some comments may be shown as answers.

Can someone explain these options of DataSource in Grid?

2 Answers 262 Views
Grid
This is a migrated thread and some comments may be shown as answers.
chobo2
Top achievements
Rank 1
Veteran
chobo2 asked on 16 Dec 2020, 10:36 PM

Hi

I am having trouble understanding what some of these options do and having trouble to find documentation about it

 

@Html.Kendo().Grid<Model>().Name().Columns().DataSource(source => source.Ajax().PageSize(20).Model(m => model.Id(p =>p.Id)).ServerOperation(false).Read(read => read.Action("","").Data("getId")

 

I don't understand what Model does in Datasource, ServerOperation(false), and .Data("getId").

I also have a endpoint 

public ActionResult GetData([DataSourceRequest] DataSourceRequest, int id){ // some stuff }

 

 

I understand this is hit by the Action Method in read but I don't understand why most of the DataSourceRquest in empty (for instance page size is 0, when I would think it would be 20).

 

 

 

2 Answers, 1 is accepted

Sort by
0
chobo2
Top achievements
Rank 1
Veteran
answered on 16 Dec 2020, 10:40 PM
Also what does .Ajax() do when it is empty? I thought this would keep hitting the endpoint when going to the next page but it seems like all the data loads up in 1 go.
0
Nikolay
Telerik team
answered on 21 Dec 2020, 12:40 PM

Hello Michael,

The Telerik UI Grid HtmlHelper for ASP.NET Core is a server-side wrapper for the Kendo UI Grid widget. The code you have pointed to is an HmlHelper declaration of the Grid jQuery widget. In the browser, the HtmlHleper will render to the JavaScript.

Here is what each of the Grid HtmlHelper components refers to:

- <Model>

This is the model the Grid will bind to. This code:

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

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

Is equivalent to:

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()

- DataSource

The DataSource is an abstraction for using local data or remote data. In most cases, the DataSource definition is declared as part of the configurations for the Telerik UI HTML Helpers. 

- ServerOperation(false)

When ServerOperation is enabled, all data operations like paging, sorting, grouping, etc. will be performed on the server-side. When they are disabled, those operations will be performed on the client and the entire data set will be available for the DataSource:

- Read.Data("getId")

Via the Data method, which specifies a JavaScript function, additional parameters can be sent to the Controller.

Let me know if you have further questions.

Regards,
Nikolay
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
chobo2
Top achievements
Rank 1
Veteran
Answers by
chobo2
Top achievements
Rank 1
Veteran
Nikolay
Telerik team
Share this question
or