KendoUI Grid with WebAPI

Patrik Johansson

I have a newly created Telerik project to which I've only added Entity Framework and WebAPI. I've used the KendoUI scaffolder to create a simple Grid from a very simple model (and hopefully corrected the errors in the scaffolder in the latest version). Read (GET) and Create (POST) work fine, but Update and Delete doesn't work. When trying to do Update or Delete, I get:

kendo.all.min.js:9 "Uncaught TypeError: e.replace is not a function"

Any idea of what is wrong? I am quite sure it is something quite simple.

On a side note, dataSource.type of "webapi" is intended to be used only with the Kendo UI MVC wrappers, when the kendo.aspnetmvc.js is registered. Unless you have a special reason to set this dataSource.type value and have implemented the server code in accordance with the Kendo UI MVC Grid documentation, I recommend removing it.

Patrik Johansson

Could you please tell what i actually needed to change in order to get this to work? I've already been through most of the links you gave and that didn't make me solve this.

"On a side note, dataSource.type of "webapi" is intended to be used only
with the Kendo UI MVC wrappers, when the kendo.aspnetmvc.js is
registered. Unless you have a special reason to set this dataSource.type
value and have implemented the server code in accordance with the Kendo
UI MVC Grid documentation, I recommend removing it."

This is code generated by Teleriks own scaffolder by choosing the Kendo UI grid (non MVC) and selecting WebAPI from the Datasource type menu. And now you are telling us that the generate code is wrong and that Kendo UI non MVC version doesn't even support WebAPI? Or am I missing something here?

If Kendo UI HTML5/JS does not support WebAPI (which is bad in itself), what Datasource Types does it actually support and which of these are prefered? In the Scaffolder there is also "AJAX" (which seem to work fine) and "Server" which doesn't say anything to me what it is.

Please enlighten us :)

Patrik Johansson

OK, turns out the code generated by Teleriks scaffolder is, for the lack of a better word, crap. Not even close to working, which makes the scaffolder kind of pointless. Looking at the video Dimo gave in his post, I was able to get this to work, but surely there must be a better way to implement a WebAPI as datasource than that?

Patrik Johansson

To help others I post some code that ACTUALLY WORKS with the Kendo UI Datasource unlike the code produced by the Kendo UI Scaffolder in the latest version of Kendo UI. Must say I am a bit frustrated and concerned about the scaffolding problems in this release of Kendo UI, I mean, the hole point of having a scaffolder is that it generates working code, it not it's quite pointless. Anyway, here we go:

Dimo

I admit that the current Scaffolder suffers from some issues and I understand your disappointment. We will do our best to address these as soon as possible. To be more specific, generating type:"webapi" is an oversight on our end, as it assumes that the kendo.aspnetmvc.js script is available, which may not be the case for developers that use Kendo UI Professional only. We will need to choose one of several options - remove the generated dataSource type, remove the dependency to the Kendo UI MVC script, make the dependency clear to developers, or abandon this scenario and remove it from the Scaffolder. We still need to evaluate all options before making a decision, but at this point we are inclined towards the third option and listing the required dependencies in the Scaffolder wizard.

Patrik Johansson

Sorry for coming down so hard on the scaffolder but I think this is a really important area and something Telerik definitely should invest some time and money in. Scaffolding and code-generation tools are really important to me as a developer, to enable me to be as productive as possible. Especially when it comes to "simple and boring" stuff like creating for example 15 very similar CRUD pages. What I've read about the Kendo UI 2.0 plattform being released soon sounds promising, and Telerik really need to up your game here compared to the likes of DevExpress, Infragistics etc. which seem to be ahead in this area.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.