剑道 UI 网格更新功能不会触发

编程入门 行业动态 更新时间:2024-10-25 00:24:26
本文介绍了剑道 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" } } } } });

这是我的剑道 UI 网格.它读起来很好,但问题是当我更改网格单元内联时,它不会触发 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":

And change your editable specification to "inline":

editable: "inline",

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

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

为了充分体现这一点,您必须从命令中提供相关方法的实现,例如更新、创建等...您可以在 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.

还有这个批量编辑的例子.

更多推荐

剑道 UI 网格更新功能不会触发

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

发布评论

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

>www.elefans.com

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