javascript - 如何判断剑道 UI 网格中的 destroy 命令销毁了什么?

标签 javascript kendo-ui kendo-grid

我正在使用 Kendo UI 2013.2.716 和 JQuery 2.0.3,我正在放置 grid在我的页面上,我的问题是:

Does anyone know how to tell what has been destroyed by the destroy command from the grid?

例如:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <link href="kendo.common.min.css" rel="stylesheet" />
    <link href="kendo.default.min.css" rel="stylesheet" />
    <script type="text/javascript" src="jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="kendo.all.min.js"></script>
</head>
<body>            
<div id="grid"></div>
<script type="text/javascript">
    $(document).ready(function() {    
        var products = [];
        for(var i = 1; i <= 40; i++) {
            products.push({
                ProductId: i,
                ProductName: "Product " + i
            });
        }    
        $("#grid").kendoGrid({
            dataSource: {
                data: products,
                schema: {
                    model: {
                        id: "ProductId",
                        fields: {
                            ProductName: { type: "string" },
                        }
                    }
                },
                requestEnd: function (e) {
                    if (e.type === "destroy") {
                        alert("OK, so something got destroyed, but what??");
                    }
                }
            },
            editable: "inline",
            columns: [
                "ProductName",
                { command: "destroy", title: " ", width: "100px" }
            ]
        });
    });
</script>
</body>
</html>

我在 documentation 中找到了 requestEnd 回调但我完全不知道被销毁的元素在哪里。我只需要项目的 ID,以便我可以适本地更新页面的其他部分。

我想知道我是否需要事先以某种方式捕获它。

最佳答案

您需要在数据源上配置transport 对象。在您当前的配置中,真的有任何东西被破坏了吗?当然,该项目可能会从您的网格中消失,但我想知道它是否仍在数据源中。也许这就是您的意图。

http://docs.kendoui.com/api/framework/datasource#configuration-transport.destroy

如果您只是在寻找一种方法来获取正在销毁的数据,请连接到 transport 对象的 parameterMap() 函数。在那里你可以在操作执行之前操作被删除的对象。

http://docs.kendoui.com/api/framework/datasource#configuration-transport.parameterMap

关于javascript - 如何判断剑道 UI 网格中的 destroy 命令销毁了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18379613/

相关文章:

listview - 将 View 模型绑定(bind)到 ListView

c# - Kendo UI 引用在 Razor View 中不起作用

kendo-ui - 在过滤过程中显示弹出 View

kendo-ui - 我可以在网格的数据绑定(bind)事件上传递参数吗?

javascript - 元素的最短 DOM 路径(用于 JavaScript/jQuery/Dojo)

javascript - 使用 jquery 在 TinyMCE 文本区域中选择一个范围

javascript - 记住在 Kendo-UI 中刷新时扩展的细节网格

kendo-ui - 如何在Kendo UI Grid中动态更改页面大小

javascript - 正确地将 Jquery 代码集成到 mvc 核心项目中

Javascript SVG 将箭头放置在贝塞尔曲线上