Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 94857

Ajax() datasource, but want all data in one request

$
0
0

So, I've got a grid configured as such

.DataSource(dataSource => dataSource
     .Ajax()
     .ServerOperation(false)
     .PageSize(250)
     .Read(read => read.Action("_readData", "Data", new { Id= Model.Id })))
.Scrollable(scrolling => scrolling.Enabled(true))
.Sortable()
.Pageable(paging => paging.Enabled(true)
                 .PageSizes(false)
                 .Input(false)
                 .Info(true)
                 .Numeric(false)
                 .PreviousNext(false)
                 .Messages(m => m.Display("Total Records: {2}")))

In the _readData() method of my controller, all data is retrieved and returned and the Total Records displayed reflects that.

var data = ReadData();
DataSourceResult result = data.ToDataSourceResult(request);
return Json(result);

However, the grid itself only displays 250 (the PageSize) items, even though all the items were returned, and nothing else gets displayed.

If I set Virtual(true) on the scrollable, then the grid will call out to the server again as I scroll, and once again all items data is retrieved, but it seems to only make use of the returned items PageSize at a time -- each time I scroll more than that, it calls back to the server to once again get all items, etc.

I thought ServerOperation(false) would tell the grid that all data will be requested through a single request so it wouldn't have to call back to the server each time.

The only thing I've found to work is to set PageSize(100000) (with or without virtual scrolling and with or without ServerOperation doesn't seem to affect it) to ensure that the number of items displayed is all the data that was returned, which in this case is only about 3000. This works, but seems pretty hacky.

Is there a better way to accomplish what I want?


Viewing all articles
Browse latest Browse all 94857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>