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

Grid ServerOperation(false) but server read action invoked unexpectedly

3 Answers 1892 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Veteran
Iron
Iron
Chris asked on 31 Jul 2017, 09:11 AM

HI

I found a problem about ASP.NET MVC Grid : 

After web page loaded, the grid is empty (AutoBind(false), so there have no any data),
Click any column header (will invoke column sorting) but read action invoked unexpectedly,
even if ServerOperation(false).

  @(Html.Kendo().Grid<HIS.Entity.Models.TYourModel1>()
    .Name("SelectionGrid")
    ... Sortable is true ...
    .AutoBind(false)
    .Pageable(pageable => pageable.Enabled(false))
    .Columns(columns =>
    {
      columns.Bound(column => column.xxxxx).Hidden();
    })
    .DataSource(dataSource =>
    {
      dataSource.Ajax()
        .Batch(true)
        .Model(model => model.Id(m => m.Key1))
        .PageSize(20)
        .ServerOperation(false)
        .Events(events =>
        {
          events.DefaultEvents();
        })
        .Read(read => read.Action("Selection_Read", "YourController").Data("filterSelectionGrid"));
    })
    .Events(events =>
    {
    })
    .HtmlAttributes(new { @style = "height: 85%; min-height: 180px" }))


Grid sorting ServerOperation(false) behavior not matched with description - 
'... If set to false ... paging, sorting, filtering ... will be performed client-side' : 

    // Summary:
    //     Sets the operation mode of the DataSource. By default the DataSource will make
    //     a request to the server when data for paging, sorting, filtering or grouping
    //     is needed. If set to false all data will be requested through single request.
    //     Any other paging, sorting, filtering or grouping will be performed client-side.
    //
    // Parameters:
    //   enabled:
    //     True(default) if server operation mode is enabled, otherwise false.
    public TDataSourceBuilder ServerOperation(bool enabled);


UI for ASP.NET MVC R2 2017 SP1
Visual Studio 2015 Enterprise

Best regards

Chris

 

 

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 02 Aug 2017, 05:50 AM
Hello Chris,

The described behaviour is expected.

When a column header is clicked for sorting, the Grid will make a request for all of the data, as when it is set to autoBind false, it has initially no data. The autoBind false will prevent the call to the server only after initialization, but if any interactions with the Grid are made(sorting, filtering etc) the read method will be called the first time:

(" In such scenarios data binding will occur when the change event of the dataSource instance is fired.")
http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#configuration-autoBind

Let me know if you need additional information on this matter.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Chris
Top achievements
Rank 1
Veteran
Iron
Iron
answered on 07 Aug 2017, 03:51 AM

HI

The AutoBind(false) behavior is correct, but I think the Grid should not make a request for all of the data
while ServerOperation(false) even if it has initially no data.

.AutoBind(false) > ServerOperation(true) > sorting > make a request.
.AutoBind(false) > ServerOperation(false) > sorting > NOT make a request.

Because it will break the rule of the ServerOperation(false) : 

ServerOperation : 
'...Any other paging, sorting, filtering or grouping will be performed client-side...'

Best regards

Chris

 


1
Accepted
Stefan
Telerik team
answered on 08 Aug 2017, 10:57 AM
Hello Chris,

The Grid will make a request only the first time in order to retrieve the whole data(not only the sorted page as with ServerOperations=true). This is required as otherwise when the sorting is executed nothing will happen.

In this scenario, I can suggest using the requestStart event of the Grid and a flag to determine if the request should be made. Then when the Grid can be populated with data to change the flag value. I made an example demonstrating this:

http://dojo.telerik.com/uQaqI

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#events-requestStart

I understand that this designer choice may not be expected, but changing it will produce breaking change for the widget.

Regards,
Stefan
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Veteran
Iron
Iron
Answers by
Stefan
Telerik team
Chris
Top achievements
Rank 1
Veteran
Iron
Iron
Share this question
or