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

Grid not loading big data

4 Answers 804 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peer
Top achievements
Rank 1
Peer asked on 20 Jun 2017, 09:10 AM

Hi,

I have a problem while loading data to a grid. I want to disable Pagination and show all data on one page.

 

@(Html.Kendo().Grid<WasteGridViewModel>()
      .Name("gridAllWaste")
      .Columns(columns =>
      {
          columns.Bound(c => c.LocationCode).Title(@Helpers.Localize("gridLabel_locationCode").ToString());
          columns.Bound(c => c.Timestamp).Format("{0:dd-MM-yyyy}").Title(@Helpers.Localize("gridLabel_timestamp").ToString());
          columns.Bound(c => c.Value).Title(@Helpers.Localize("gridLabel_value").ToString());          
          if (User.Identity.IsInRole(UserRole.EditWaste))
          {
              columns.Command(command =>
              {
                  command.Edit().Text(@Helpers.Localize("edit").ToString());
                  if (User.Identity.IsInRole(UserRole.AllAccess))
                  {
                      command.Custom(@Helpers.Localize("delete").ToString()).Click("openWindow");
                  }
              }).Width(250);
          }
 
      })
      .ToolBar(toolbar =>
      {
          if (User.Identity.IsInRole(UserRole.EditWaste))
          {
              toolbar.Create().Text(@Helpers.Localize("wasteGrid_add").ToString());
          }
      })
      .Scrollable(s => s.Height("auto"))
      .Groupable()
      .Sortable()
      .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("WasteEdit").DisplayDeleteConfirmation(false))
      .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
      .Pageable(pageable => pageable
          .Refresh(true)
          .PageSizes(true)
          .ButtonCount(5))
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(50)
          .Events(events =>
          {
              events.Error("errorHandler");
              events.RequestEnd("onRequestEnd");
 
          })
          .Model(model => model.Id(p => p.WasteId))
          .Read(read => read.Action("GetAllWaste", "Waste"))
          .Create(update => update.Action("CreateWaste", "Waste"))
          .Update(update => update.Action("UpdateWaste", "Waste"))
          .Destroy(update => update.Action("DeleteWaste", "Waste"))
      ))

 

Above code works fine, but when I remove Pageable and change PageSize to bigger number, for example 6000 grid doesn't show any data. I get respone 302 on my request:

Request URL:http://localhost:29786/Waste/GetAllWaste
Request Method:POST
Status Code:302 Found
Remote Address:[::1]:29786
Referrer Policy:no-referrer-when-downgrade
Repose Headers:
Cache-Control:private, s-maxage=0
Content-Length:157
Content-Type:application/json; charset=utf-8
Date:Tue, 20 Jun 2017 09:04:53 GMT
Location:/Error/?aspxerrorpath=/Waste/GetAllWaste
Server:Microsoft-IIS/10.0
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:5.2
X-Powered-By:ASP.NET
X-SourceFiles:=?UTF-8?B?QzpcUmVwb3NpdG9yaWVzXFdhc3RlXHNyY1xFbmdpZS5XYXN0ZVxFbmdpZS5XYXN0ZVxXYXN0ZVxHZXRBbGxXYXN0ZQ==?=

 

Thanks in advance for any help.

4 Answers, 1 is accepted

Sort by
0
Peer
Top achievements
Rank 1
answered on 20 Jun 2017, 09:31 AM

Ok, problem solved :)

The solution was to increase JSON length in controller return method:

return new JsonResult() { Data = _wasteService.GetAllWastesForGrid().ToDataSourceResult(request), JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue };
0
Viktor Tachev
Telerik team
answered on 22 Jun 2017, 08:25 AM
Hello Peer,

Indeed when a lot of data is passed from the server the MaxJsonLength may be exceeded. You can modify it, however, have in mind that this can result in decreased performance in some scenarios. 

When having a large number of records it is recommended to enable paging for the Grid component. This way only the items for the current page can be returned from the server.

Regards,
Viktor Tachev
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
Archieval
Top achievements
Rank 1
Veteran
answered on 22 Oct 2020, 03:57 AM
is this available also for telerik mvc? i already know the basic and custom paging for ajax, but not in mvc
0
Viktor Tachev
Telerik team
answered on 23 Oct 2020, 11:25 AM

Hi Archieval,

 

It is possible to change the default maxJSONLength value in MVC. Check out the stackoverflow thread below that describes the approach:

https://stackoverflow.com/a/13961055

 

That said, if you have a lot of data that should be returned to the Grid I recommend enabling server operations and turning on paging. This way only the items needed for a given page will be returned from the server. This would decrease the amount of data returned from the server and the information should be loaded faster. If you would like more information on using paging with server operations enabled you would find the article below interesting.

https://docs.telerik.com/aspnet-mvc/html-helpers/data-management/grid/paging

 

Regards,
Viktor Tachev
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
Peer
Top achievements
Rank 1
Answers by
Peer
Top achievements
Rank 1
Viktor Tachev
Telerik team
Archieval
Top achievements
Rank 1
Veteran
Share this question
or