We have a table with a large amount of data (in the millions of rows). We are using a stored procedure to fetch the records and binding that data with kendo grid using mvc approach. But we want to fetch only desired rows from table instead of getting the whole set of data in one go and then make filtering, sorting, paging options on that.
Would it be possible to fetch only one page of rows at a time? Please help and suggest some approach.
First, you should have some paging logic inside your stored procedure. You can take a look at this blog post for suggestions: https://sqlperformance.com/2015/01/t-sql-queries/pagination-with-offset-fetch
Then, in your view, set your grid's data source to call a custom action in your controller. Make sure you enable paging. Something like this:
Finally in your controller create the action and make it expect a DataSourceRequest parameter. That parameter will be receiving an object from the grid, which will include the page size and the current page number. You can use those to pass them to your stored procedure and make it fetch only that page of data. It will be something like this:
You can see an example of ajax datasource on Telerik's website: Look at http://demos.telerik.com/aspnet-mvc/grid/customajaxbinding.
I've just done it like this (note: I'm using Dapper and EF)
GridBinder