剑道网格删除命令不起作用 [英] kendo grid delete command not working

查看:14
本文介绍了剑道网格删除命令不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用剑道用户界面工具开发了一个网络应用程序,并且有一个带有批量编辑模式的剑道网格..

但是当我按下剑道网格中任何记录的删除按钮时,它会从网格中的列表中删除,但实际上不在数据源中.当我重新加载页面或网格时,删除的项目仍然存在..

这是我的网格代码

<script type="text/javascript">$("#submitMarketUser").click(function () {var grid = $("#grid").data("kendoGrid");var dataSource = new kendo.data.DataSource({运输: {读: {url: "WholeSaleTrade/GetTradeProductDetail",数据类型:json",数据: {测试:$("#Names").val()}},破坏: {url: "WholeSaleTrade/DeletePro",类型:POST",数据类型:jsonp",数据: {DAKy: $("#Names").val(),DIKy: $("#btntxt").val()}},创建: {url: "WholeSaleTrade/CreateProduct",类型:POST",数据类型:jsonp",数据: {AKy: $("#Names").val(),IKy: $("#btntxt").val()}}},页面大小:5,架构:{模型: {id: "产品密钥",字段:{产品密钥:{ 可假,可为空:真},产品名称:{ 验证:{ 要求:真实}}}}}});$("#grid").kendoGrid({数据源:数据源,可真实,工具栏:[创建",保存"],自动绑定:真,可分页:真实,列: [{ 字段:产品名称",标题:产品名称",编辑器:函数(容器,选项){var 模型 = options.model;$('<input id="btntxt" name="' + options.field + '"/>').appendTo(container).kendoComboBox({数据源: {类型:POST",运输: {读: {url: "市场信息/填充产品",成功:功能(数据){var prod = 数据[0];model.set("ProductName", prod.ItmNm);model.set("ItmKy", prod.ItmKy);model.set("UserKey", $("#Names").val());}}}},dataValueField: "ItmKy",数据文本字段:ItmNm"});}},{ 命令:[摧毁"],标题:&nbsp;"}]});});

无法确定问题出在哪里,请有人帮我解决这个问题.

解决方案

删除不起作用的三个常见原因:


1. 未将 grideditable 设置为 inlinepopup.删除的项目将通过传输销毁自动处理,仅适用于内联"/弹出"编辑模式.例如:

可{模式:内联",}//或者可内联"


2.如果在您的数据源上,您将 batch 标志设置为 true,这意味着数据源将使在您告诉它之后调用,例如调用 sync().例如:

var dataSource = new kendo.data.DataSource({批次:真实,//.....});//... 在某些地方,例如在保存按钮单击事件中调用以下行:数据源.sync();


3.您应该将id定义为数据源model中数据库字段名称的主键.例如:

 模型:{id: "产品ID",字段:{产品 ID:{ 可假,可为空:真},}}

<小时>所以你的代码的问题是第一个,即你没有将 editable 设置为 inlinepopup

i have developed a web application using kendo ui tools and theres a kendo grid with batch edit mode..

but when i press the delete button for any record in kendo grid it will erase from the list in grid but actually not in the data source.when i reload the page or grid the deleted item will still exist..

here is the code of my grid

<div id="grid">
        </div>
        <script type="text/javascript">

            $("#submitMarketUser").click(function () {
                var grid = $("#grid").data("kendoGrid");
                var dataSource = new kendo.data.DataSource({
                    transport: {
                        read: {
                            url: "WholeSaleTrade/GetTradeProductDetail",
                            dataType: "json",
                            data: {
                                test: $("#Names").val()
                            }
                        },
                        destroy: {
                            url: "WholeSaleTrade/DeletePro",
                            type: "POST",
                            dataType: "jsonp",
                            data: {
                                DAKy: $("#Names").val(),
                                DIKy: $("#btntxt").val()
                            }
                        },
                        create: {
                            url: "WholeSaleTrade/CreateProduct",
                            type: "POST",
                            dataType: "jsonp",
                            data: {
                                AKy: $("#Names").val(),
                                IKy: $("#btntxt").val()
                            }
                        }
                    },
                    pageSize: 5,
                    schema: {
                        model: {
                            id: "ProductKey",
                            fields: {
                                ProductKey: { editable: false, nullable: true },
                                ProductName: { validation: { required: true} }
                            }
                        }
                    }
                });
                $("#grid").kendoGrid({
                    dataSource: dataSource,
                    editable: true,
                    toolbar: ["create", "save"],
                    autobind: true,
                    pageable: true,
                    columns: [
                        { field: "ProductName", title: "Product Name",
                            editor: function (container, options) {
                                var model = options.model;
                                $('<input id="btntxt" name="' + options.field + '"/>').appendTo(container).kendoComboBox({
                                    dataSource: {
                                        type: "POST",
                                        transport: {
                                            read: {
                                                url: "MarketInformation/PopulateProducts",
                                                success: function (data) {
                                                    var prod = data[0];
                                                    model.set("ProductName", prod.ItmNm);
                                                    model.set("ItmKy", prod.ItmKy);
                                                    model.set("UserKey", $("#Names").val());
                                                }
                                            }
                                        }
                                    },

                                    dataValueField: "ItmKy",
                                    dataTextField: "ItmNm"
                                });
                            }
                        },
                        { command: ["destroy"], title: "&nbsp;" }
                    ]
                });
            });

        </script>

can not identify that where is the fault going and can somebody please help me to solve this matter.

解决方案

There are three common reasons delete won't work:


1. Not setting editable of grid to inline or popup. The deleted items will be automatically processed through transport destroy only for "inline"/"popup" edit modes. Ex:

editable: {
   mode: "inline",
}
//or
editable: "inline"


2. If on your datasource, you have the batch flag set to true, this means the datasource will make the call only after you tell it to, e.g calling sync(). Ex:

var dataSource = new kendo.data.DataSource({
    batch: true,
    //.....
});
//... in some where e.g in a save button click event call the following line:
dataSource.sync();


3. You should define id to your primary key of database field name inside model of datasource. Ex:

   model: {
        id: "ProductID",
        fields: {
            ProductID: { editable: false, nullable: true },
        }
    }


So the problem with your code is first one, i.e you did not set editable to inline or popup

这篇关于剑道网格删除命令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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