Jquery 如何使用enter按键事件在剑道格网中添加新记录

Jquery 如何使用enter按键事件在剑道格网中添加新记录,jquery,kendo-ui,keypress,kendo-grid,enter,Jquery,Kendo Ui,Keypress,Kendo Grid,Enter,我使用一些剑道ui工具开发了一个简单的web应用程序 在那里,我使用了剑道网格工具来查看和插入产品详细信息的数据 但我的问题是在编辑模式下,当我按enter键插入新记录时,我需要转到同一行的下一个单元格下一列,在同一行的最后一列之后,再转到下一行新记录 下面是我在myview index.cshtml中用于网格的代码 button class="k-button" id="batchGrid"> Batch Edit</button> <div id="e

我使用一些剑道ui工具开发了一个简单的web应用程序

在那里,我使用了剑道网格工具来查看和插入产品详细信息的数据

但我的问题是在编辑模式下,当我按enter键插入新记录时,我需要转到同一行的下一个单元格下一列,在同一行的最后一列之后,再转到下一行新记录

下面是我在myview index.cshtml中用于网格的代码

    button class="k-button" id="batchGrid">
    Batch Edit</button>
<div id="example" class="k-content">
    <div id="batchgrid">
    </div>
</div>
<script>
    $("#batchGrid").click(function () {
        var crudServiceBaseUrl = "http://demos.kendoui.com/service",
                        dataSource = new kendo.data.DataSource({
                            transport: {
                                read: {
                                    url: crudServiceBaseUrl + "/Products",
                                    dataType: "jsonp"
                                },
                                update: {
                                    url: crudServiceBaseUrl + "/Products/Update",
                                    dataType: "jsonp"
                                },
                                destroy: {
                                    url: crudServiceBaseUrl + "/Products/Destroy",
                                    dataType: "jsonp"
                                },
                                create: {
                                    url: crudServiceBaseUrl + "/Products/Create",
                                    dataType: "jsonp"
                                },
                                parameterMap: function (options, operation) {
                                    if (operation !== "read" && options.models) {
                                        return { models: kendo.stringify(options.models) };
                                    }
                                }
                            },
                            batch: true,
                            pageSize: 20,
                            schema: {
                                model: {
                                    id: "ProductID",
                                    fields: {
                                        ProductID: { editable: false, nullable: true },
                                        ProductName: { validation: { required: true} },
                                        UnitPrice: { type: "number", validation: { required: true, min: 1} },
                                        Discontinued: { type: "boolean" },
                                        UnitsInStock: { type: "number", validation: { min: 0, required: true} }
                                    }
                                }
                            }
                        });

        $("#batchgrid").kendoGrid({
            dataSource: dataSource,
            navigatable: true,
            filterable: true,
            pageable: true,
            height: 430,
            width: 300,
            toolbar: ["create", "save", "cancel"],
            columns: [
                            "ProductName",
                            { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "130px" },
                            { field: "UnitsInStock", title: "Units In Stock", width: "130px" },
                            { field: "Discontinued", width: "130px" },
                            { command: ["destroy"], title: "&nbsp;", width: "100px"}],
            editable: true
        });
    });
</script>
如何处理剑道网格中的enter键按下事件并遍历列和行


请帮帮我。

试试这段代码,它可以帮助您在按enter键的同时移动下一个单元格

 $(document).ready(function () {
        $("#batchGrid").on("click", "td", function (e) {
            var rowIndex = $(this).parent().index();
            var cellIndex = $(this).index();
            window.onkeydown = function (event) {
                if (event.keyCode == 13) {
                    $("#batchGrid").data("kendoGrid").editCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").next().focusin($("#batchGrid").data("kendoGrid").closeCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").parent())));

                }
            }

        });
    });
试试这个

 $("#batchgrid").on("click", "td", function (e) {

            var rowIndex = $(this).parent().index();
            var cellIndex = $(this).index();
            $(".k-textbox").on("keydown", function (event) {
                if (event.keyCode == 13) {
                    $("#batchgrid").data("kendoGrid").editCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").next().focusin($("#batchgrid").data("kendoGrid").closeCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").parent())));
                    return false;
                }
            });

        });
试试这个代码

$("#batchgrid").on("click", "td", function (e) {

            var rowIndex = $(this).parent().index();
            var cellIndex = $(this).index();
            $("input").on("keydown", function (event) {
                if (event.keyCode == 13) {
                    $("#batchgrid").data("kendoGrid").editCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").next().focusin($("#batchgrid").data("kendoGrid").closeCell($(".k-grid-content").find("table").find("tbody").find("tr:eq(" + rowIndex + ")").find("td:eq(" + cellIndex + ")").parent())));
                    return false;
                }
            });

        });

我尝试了你的代码,但没有给出任何积极的反馈。当我按enter键时,它不会移动到下一个单元格。请注意这里。到目前为止,如果我只使用文本框,它工作正常,但问题是当我在组合框或复选框中按enter键时,它工作不正常。如何解决?我真的很抱歉,先生,但是问题仍然存在。我认为问题是组合框。当我在文本框中按enter键时,它将跳转到下一个单元格,无论那里有什么,但当我在组合框或复选框或下拉框中按enter键时,它将不会像在文本框中那样正常工作。如果你能给我一个适当的解决方案。我真的很抱歉,先生,但问题仍然存在。我认为问题是组合框。当我在文本框中按enter键时,它将跳转到下一个单元格,无论有什么,但当我在组合框、复选框或下拉框中按enter键时,它将无法像在文本框中那样正常工作。如果您能给我一个适当的解决方案,请。