Can someone explain these options of DataSource in Grid?

3 posts, 0 answers
  1. chobo2
    chobo2 avatar
    4 posts
    Member since:
    May 2014

    Posted 16 Dec 2020 Link to this post

    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. chobo2
    chobo2 avatar
    4 posts
    Member since:
    May 2014

    Posted 16 Dec 2020 Link to this post

    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.
  3. Nikolay
    Admin
    Nikolay  avatar
    301 posts

    Posted 21 Dec 2020 Link to this post

    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/.

Back to Top