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

Existing API as datasource vs DataSourceRequest

2 Answers 306 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Johan
Top achievements
Rank 1
Johan asked on 04 Oct 2018, 12:22 AM

We have a Web API where the controller classes implements ApiController. 

The CRUD-operations looks like:

public IHttpActionResult Get()
public IHttpActionResult Get(int id)
public int Post(Company company)
public void Put(Company company)
public void Delete(int id)

Adding a Kendo UI ASP.NET MVC Grid that view data works, but we got stuck binding to datasource when we tried to implement inline-editable rows. 

The API methods on the demo page, https://demos.telerik.com/aspnet-mvc/grid, takes a DataSourceRequest as a parameter. 
Here it gets confusing especially when the documentation is not so comprehensive.

Can't we just use our API as it is, do we need to create yet another class where all the CRUD-operations takes the DataSourceRequest parameter?

 

2 Answers, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 05 Oct 2018, 04:54 PM
Hello, Johan,

The recommended way to use the Kendo UI Grid when bound to WebApi is demonstrated in the demo at:

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

Using the predefined web API type data source allows you to take advantage of server operations effortlessly as well as the model binding mechanism. Can you let me know if server operations(paging, sorting, grouping, filtering, aggregating) are not desirable?

I noticed that the update signature does not follow the Web API convention, what is the reason for that?

public HttpResponseMessage Put(int id, ViewModel product)

This may mean that in your scenario is better to use a Custom DataSource instead:

https://demos.telerik.com/aspnet-mvc/grid/custom-datasource

If you can provide some additional details about the desired outcome, I may be able to give you more suitable and concrete suggestions.

Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Johan
Top achievements
Rank 1
answered on 08 Oct 2018, 02:23 PM

Hi Alex,

I will try to bound to WebApi instead. 

Oh, that's a typo. The api actually takes the id as an argument. 

 

Thanks so far! 

Tags
Grid
Asked by
Johan
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Johan
Top achievements
Rank 1
Share this question
or