Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 剑道格网按键输入按键事件处理_Jquery_Kendo Ui_Telerik_Kendo Grid_Telerik Grid - Fatal编程技术网

Jquery 剑道格网按键输入按键事件处理

Jquery 剑道格网按键输入按键事件处理,jquery,kendo-ui,telerik,kendo-grid,telerik-grid,Jquery,Kendo Ui,Telerik,Kendo Grid,Telerik Grid,我有一个剑道网格。我想处理enter键向下事件。如果用户在剑道单元格内按enter键,则必须聚焦并将下一个单元格置于编辑模式。(光标应移动到下一个网格单元格)。 我尝试过这个代码 $("#list").on("focus", "td", function (e) { $("input").on("keydown", function (event) { if (event.keyCode == 13) { set

我有一个剑道网格。我想处理enter键向下事件。如果用户在剑道单元格内按enter键,则必须聚焦并将下一个单元格置于编辑模式。(光标应移动到下一个网格单元格)。 我尝试过这个代码

      $("#list").on("focus", "td", function (e) {         
     $("input").on("keydown", function (event) {
         if (event.keyCode == 13) {
             setTimeout(function () {
                 var curCell = $("#list").find(".k-state-selected")
                 var eCell = $("#list").find(".k-edit-cell")

                 curCell.removeClass("k-state-selected");
                 curCell.removeClass("k-state-focused");
                 curCell.removeAttr("data-role");
                 curCell.next().addClass("k-state-selected");
                 curCell.next().addClass("k-state-focused");
                 try {                         $('#list').data('kendoGrid').closeCell(eCell);
                 } catch (ex) {
                 }
                 $('#list').data('kendoGrid').select();                     
                 $('#list').data('kendoGrid').editCell(curCell.next());

             }, 50);

         }
     });
 });
 }


或者是否有任何方法可以用enter键覆盖tab键功能(因为tab键可以正常工作)

请使用下面的代码片段进行尝试

<!DOCTYPE html>
<html>
<head>
    <title>Jayesh Goyani</title>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2015.2.902/styles/kendo.common-bootstrap.min.css" />
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2015.2.902/styles/kendo.bootstrap.min.css" />
    <script src="https://kendo.cdn.telerik.com/2015.2.902/js/jquery.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2015.2.902/js/kendo.all.min.js"></script>
</head>
<body>
    <div id="list"></div>
    <script>
        $(document).ready(function () {
            function onDataBound(e) {
                $("#list").on("focus", "td", function (e) {
                    $("input").on("keydown", function (event) {
                        if (event.keyCode == 13) {
                            setTimeout(function () {
                                var curCell = $("#list").find(".k-state-selected")
                                var eCell = $("#list").find(".k-edit-cell")

                                curCell.removeClass("k-state-selected");
                                curCell.removeClass("k-state-focused");
                                curCell.removeAttr("data-role");
                                curCell.next().addClass("k-state-selected");
                                curCell.next().addClass("k-state-focused");
                                try {
                                    $('#list').data('kendoGrid').closeCell(eCell);
                                } catch (ex) {
                                }
                                $('#list').data('kendoGrid').select(); $('#list').data('kendoGrid').editCell(curCell.next());

                                if ($(curCell.next()).find('select')) {
                                    $($(curCell.next()).find('select')).data("kendoDropDownList").open()
                                }

                            }, 50);

                        }
                    });
                });
            }

            var savings = [{
                month: "January",
                saving: "$200",
                kind: 1
            }, {
                month: "March",
                saving: "$100",
                kind: 1
            }, {
                month: "March sdjhf as dfjh;as",
                saving: "$100",
                kind: 1
            }, {
                month: "March",
                saving: "$100",
                kind: 1
            }, {
                month: "March",
                saving: "$10000",
                kind: 1
            }, {
                month: "December",
                saving: "$100",
                kind: 1
            }, {
                month: "March",
                saving: "$100",
                kind: 1
            }, {
                month: "March",
                saving: "$100",
                kind: 2
            }, {
                month: "March",
                saving: "$100",
                kind: 3
            }, {
                month: "March",
                saving: "$100",
                kind: 1
            }];

            var savingsDataSource = new kendo.data.DataSource({
                data: savings
            });


            var grid = $("#list").kendoGrid({
                dataSource: savingsDataSource,
                navigatable: true,
                pageable: true,
                height: 400,
                selectable: "cell",
                toolbar: ["create", "save", "cancel"],
                columns: [{
                    field: "month",
                    title: "Month"
                }, {
                    field: "saving"
                }, {
                    field: "saving"
                }, {
                    field: "kind",
                    values: [{
                        value: 1,
                        text: "Kind1"
                    }, {
                        value: 2,
                        text: "Kind2"
                    }, {
                        value: 3,
                        text: "Kind3"
                    }]
                }],
                editable: true,
                dataBound: onDataBound,

            }).data("kendoGrid");


            var specialKeys = [kendo.keys.UP, kendo.keys.DOWN];

            function edit(e) {
                //$("#list").find(".k-state-selected").focus();
                //e.container.find("td:eq(1) input").focus();

            }
        });
    </script>
</body>
</html>

贾耶什·戈亚尼
$(文档).ready(函数(){
函数onDataBound(e){
$(“#列表”)。关于(“焦点”,“td”,函数(e){
$(“输入”)。在(“向下键”上,函数(事件){
如果(event.keyCode==13){
setTimeout(函数(){
var curCell=$(“#列表”).find(“.k-state-selected”)
var eCell=$(“#list”).find(“.k-edit-cell”)
curCell.removeClass(“k-state-selected”);
removeClass(“k状态聚焦”);
curCell.removeAttr(“数据角色”);
curCell.next().addClass(“k-state-selected”);
curCell.next().addClass(“k-state-focused”);
试一试{
$('#list').data('kendoGrid').closeCell(eCell);
}捕获(ex){
}
$('#list').data('kendoGrid').select();$('#list').data('kendoGrid').editCell(curCell.next());
if($(curCell.next()).find('select')){
$($(curCell.next()).find('select')).data(“kendoDropDownList”).open()
}
}, 50);
}
});
});
}
var储蓄=[{
月份:“一月”,
节省:“$200”,
种类:1
}, {
月份:“三月”,
节省:“$100”,
种类:1
}, {
月份:“三月sdjhf作为dfjh;作为”,
节省:“$100”,
种类:1
}, {
月份:“三月”,
节省:“$100”,
种类:1
}, {
月份:“三月”,
节省:“$10000”,
种类:1
}, {
月份:“12月”,
节省:“$100”,
种类:1
}, {
月份:“三月”,
节省:“$100”,
种类:1
}, {
月份:“三月”,
节省:“$100”,
种类:2
}, {
月份:“三月”,
节省:“$100”,
种类:3
}, {
月份:“三月”,
节省:“$100”,
种类:1
}];
var savingsDataSource=new kendo.data.DataSource({
数据:节省
});
变量网格=$(“#列表”).kendoGrid({
数据源:savingsDataSource,
可导航:是的,
pageable:对,
身高:400,
可选:“单元格”,
工具栏:[“创建”、“保存”、“取消”],
栏目:[{
字段:“月”,
标题:“月”
}, {
字段:“保存”
}, {
字段:“保存”
}, {
字段:“种类”,
价值观:[{
价值:1,
案文:“1”
}, {
价值:2,
文本:“Kind2”
}, {
价值:3,
案文:“第3条”
}]
}],
是的,
数据绑定:onDataBound,
}).数据(“kendoGrid”);
var specialKeys=[kendo.keys.UP,kendo.keys.DOWN];
功能编辑(e){
//$(“#列表”).find(“.k-state-selected”).focus();
//e、 container.find(“td:eq(1)input”).focus();
}
});

如果有任何问题,请告诉我。

请尝试使用下面的代码片段

<!DOCTYPE html>
<html>
<head>
    <title>Jayesh Goyani</title>
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2015.2.902/styles/kendo.common-bootstrap.min.css" />
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2015.2.902/styles/kendo.bootstrap.min.css" />
    <script src="https://kendo.cdn.telerik.com/2015.2.902/js/jquery.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2015.2.902/js/kendo.all.min.js"></script>
</head>
<body>
    <div id="list"></div>
    <script>
        $(document).ready(function () {
            function onDataBound(e) {
                $("#list").on("focus", "td", function (e) {
                    $("input").on("keydown", function (event) {
                        if (event.keyCode == 13) {
                            setTimeout(function () {
                                var curCell = $("#list").find(".k-state-selected")
                                var eCell = $("#list").find(".k-edit-cell")

                                curCell.removeClass("k-state-selected");
                                curCell.removeClass("k-state-focused");
                                curCell.removeAttr("data-role");
                                curCell.next().addClass("k-state-selected");
                                curCell.next().addClass("k-state-focused");
                                try {
                                    $('#list').data('kendoGrid').closeCell(eCell);
                                } catch (ex) {
                                }
                                $('#list').data('kendoGrid').select(); $('#list').data('kendoGrid').editCell(curCell.next());

                                if ($(curCell.next()).find('select')) {
                                    $($(curCell.next()).find('select')).data("kendoDropDownList").open()
                                }

                            }, 50);

                        }
                    });
                });
            }

            var savings = [{
                month: "January",
                saving: "$200",
                kind: 1
            }, {
                month: "March",
                saving: "$100",
                kind: 1
            }, {
                month: "March sdjhf as dfjh;as",
                saving: "$100",
                kind: 1
            }, {
                month: "March",
                saving: "$100",
                kind: 1
            }, {
                month: "March",
                saving: "$10000",
                kind: 1
            }, {
                month: "December",
                saving: "$100",
                kind: 1
            }, {
                month: "March",
                saving: "$100",
                kind: 1
            }, {
                month: "March",
                saving: "$100",
                kind: 2
            }, {
                month: "March",
                saving: "$100",
                kind: 3
            }, {
                month: "March",
                saving: "$100",
                kind: 1
            }];

            var savingsDataSource = new kendo.data.DataSource({
                data: savings
            });


            var grid = $("#list").kendoGrid({
                dataSource: savingsDataSource,
                navigatable: true,
                pageable: true,
                height: 400,
                selectable: "cell",
                toolbar: ["create", "save", "cancel"],
                columns: [{
                    field: "month",
                    title: "Month"
                }, {
                    field: "saving"
                }, {
                    field: "saving"
                }, {
                    field: "kind",
                    values: [{
                        value: 1,
                        text: "Kind1"
                    }, {
                        value: 2,
                        text: "Kind2"
                    }, {
                        value: 3,
                        text: "Kind3"
                    }]
                }],
                editable: true,
                dataBound: onDataBound,

            }).data("kendoGrid");


            var specialKeys = [kendo.keys.UP, kendo.keys.DOWN];

            function edit(e) {
                //$("#list").find(".k-state-selected").focus();
                //e.container.find("td:eq(1) input").focus();

            }
        });
    </script>
</body>
</html>
  $("#GridID").keypress(function (e) {
            if (e.keyCode === 13) {
                e.preventDefault();
            }
        });

贾耶什·戈亚尼
$(文档).ready(函数(){
函数onDataBound(e){
$(“#列表”)。关于(“焦点”,“td”,函数(e){
$(“输入”)。在(“向下键”上,函数(事件){
如果(event.keyCode==13){
setTimeout(函数(){
var curCell=$(“#列表”).find(“.k-state-selected”)
var eCell=$(“#list”).find(“.k-edit-cell”)
curCell.removeClass(“k-state-selected”);
removeClass(“k状态聚焦”);
curCell.removeAttr(“数据角色”);
curCell.next().addClass(“k-state-selected”);
curCell.next().addClass(“k-state-focused”);
试一试{
$('#list').data('kendoGrid').closeCell(eCell);
}捕获(ex){
}
$('#list').data('kendoGrid').select();$('#list').data('kendoGrid').editCell(curCell.next());
if($(curCell.next()).find('select')){
$($(curCell.next()).find('select')).data(“kendoDropDownList”).open()
}
},