kendo UI网格更新功能不会触发

编程入门 行业动态 更新时间:2024-10-25 02:21:28
本文介绍了kendo UI网格更新功能不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 $('#usersGrid').kendoGrid({ columns: [ { field: "UserName", title: "Display name", width: "140px" }, { field: "Unit", title: "Unit", width: "140px" }, { field: "Email", title: "E-mail", width: "140px" }, { field: "Indienst", title: "Indienst", width: "140px" }, { field: "Uitdienst", title: "Uitdienst", width: "140px" }, { field: "Roles", title: "Roles" }, { command: { text: "edit", click: openEdit } } ], editable: { update: true, create: true }, dataSource: { transport: { read: function (options) { $.ajax({ url: "/Administration/GetUserList", dataType: "json", data: { indienst: function () { return indienst; } }, success: function (data) { $("#usersGrid").data('kendoGrid').dataSource.data(data); } }); }, update: function (options) { alert('not firing'); } } }, schema: { model: { id: "UserId", fields: { UserId: { editable: false, type: "int" }, UserName: { type: "string" }, Unit: { editable: false, type: "string" }, Email: { type: "string" }, Indienst: { type: "string" }, Uitdienst: { type: "string" }, Roles: { editable: false, type: "string" } } } } });

这是我的Kendo UI网格.一切正常,但问题是当我更改网格单元格 inline 时,它不会触发datasource.transport.update调用.为什么不呢?

This is my kendo UI grid. It's reading fine, but the problem is that it wont fire the datasource.transport.update call when I change a grid cell inline. Why won't it?

我已经确保指定了一个id列,并且传输CRUD函数都属于同一类型(此处为函数,而不是url),但是我尝试将其也与url一起使用.只有transport.read会触发...

I've made sure I specified an id column and that the transport CRUD functions are all of the same type (functions here, not urls), but I've tried to have it work with urls as well. Only transport.read will fire...

当我检查控制台日志时,没有给出错误.

when I check the console logs there are no errors given.

因此,我想对其进行内联编辑.单击网格上的一个单元格,然后更改值,当您离开该单元格的焦点时,我想运行dataSource.transport.update()或任何函数.

So I want to edit it inline. Click on a cell on the grid, and change the value, when u leave focus of the cell I want dataSource.transport.update() to run, or any function at all.

jsfiddle/8tzgc/135/

在对文档进行了一些研究之后,我发现了关于change()事件的信息.通过检查它是哪种更改事件,我们可以弄清它是否是一个更新事件,并运行我们自己想要的功能.这是我更新的jsfiddle:

After doing some research on the docs I've found out about the change() event. By checking what kind of change event it is we can figure out if its an update event and run the function we want ourselves. Here's my updated jsfiddle:

jsfiddle/8tzgc/140/

如果有人想出了一种无需您自己调用更新函数的方法,那么我无所不用其极.

If anyone figures out a way that does not require calling the update function yourself, then I'm all ears.

推荐答案

要进行内联编辑,您可以直接使用 telerik演示站点.

To edit inline, you can just leverage the example from the telerik demo site.

将命令列更改为:

{ command: ["edit", "destroy"], title: " ", width: "160px" }

并将editable规范更改为"inline":

editable: "inline",

我已经使用以下解决方案编辑了您的小提琴: jsfiddle/8tzgc/136/

I have edited your fiddle with the solution: jsfiddle/8tzgc/136/

为了充分充实它,您必须提供命令中相关方法的实现,例如update,create等.您可以在 telerik演示.

In order to fully flesh this out, you would have to provide implementation for the associated methods from the command, such as update, create, etc... You can see those examples in the telerik demo.

如果您想使用自定义编辑器(下拉菜单等)进行单元格单击编辑,则此处为另一个telerik示例.

If you would like to do cell-click editing with custom editors (dropdowns, etc), here is another telerik example.

还有批量编辑示例.

更多推荐

kendo UI网格更新功能不会触发

本文发布于:2023-10-31 04:06:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544949.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:网格   功能   kendo   UI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!