Asp.net core mvc and kendo ui Pagiination

1 Answer 20 Views
Grid
Sezer
Top achievements
Rank 1
Sezer asked on 27 May 2022, 01:15 PM
I want to show the data coming from web api by paginating in kendo grid?

1 Answer, 1 is accepted

Sort by
0
Mihaela
Telerik team
answered on 01 Jun 2022, 08:04 AM

Hello Sezer,

You could achieve the desired result as per the example below:

 

//View
@(Html.Kendo().Grid<GridViewModel>()
	  .Name("grid")
          ... 
	  .Pageable() //enable the paging
	  .DataSource(dataSource =>
		  dataSource
			.WebApi() //configure the WebApi DataSource
			.Model(model =>
			{
				model.Id(p => p.ProductID); // Specify the property which is the unique identifier of the model.
			})
			.Read(read => read.Action("Get", "Product"))
	  )
)

//Controller
[Route("api/[controller]")]
public class ProductController : Controller
{
  // GET: api/values
  [HttpGet]
  public DataSourceResult Get([DataSourceRequest]DataSourceRequest request) //Get Method
  {
    return service.Read().ToDataSourceResult(request);
  }
}

Check out the complete implementation in the online demo:

https://demos.telerik.com/aspnet-core/grid/webapi

If you have any questions, feel free to let me know.

 

Regards, Mihaela Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
Sezer
Top achievements
Rank 1
Answers by
Mihaela
Telerik team
Share this question
or