kendo UI网格更新功能不会触发 [英] kendo UI grid update function wont fire

查看:90
本文介绍了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.

http://jsfiddle.net/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:

http://jsfiddle.net/8tzgc/140/

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

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

推荐答案

要进行内联编辑,您可以直接使用

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

将命令列更改为:

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

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

editable: "inline",

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

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

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

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.

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

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

还有批量编辑示例.

这篇关于kendo UI网格更新功能不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆