How do you set the data function for a Kendo DataSource using the Razor HTML Helpers?

北城以北 提交于 2019-12-11 12:41:21

问题


I'm trying to get the Kendo UI for ASP.NET MVC grid control working with a WebApi controller using OData queries. I would prefer to emit the relevant javascript using the Html helpers but I'm struggling to emit the equivalent of this:

schema: { data: function (data) { return data; } }

I've tried this:

.Schema(schema => schema.Data((object data) => { return data; }))

But I'm getting

Error: 'Kendo' is undefined

in IE and the actual JS emitted is:

"schema":{"data":Kendo.Mvc.ClientHandlerDescriptor}

What is the correct way to do this?


回答1:


A bit difficult to debug your issue without full code, but it should probably look like this:

.DataSource(dataSource => dataSource
    .Custom()
    .Schema(schema => schema.Data(data => data))
    .Type("odata")
    .Transport(t => t.Read("MyAction", "My")))


来源:https://stackoverflow.com/questions/29832460/how-do-you-set-the-data-function-for-a-kendo-datasource-using-the-razor-html-hel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!