javascript – 如何设置输入焦点在启动模态中的kendo-ui网格输入

在将kendo-ui网格移动到自举模式之前,我将点击添加行,并选择3个输入中的第一个.然后我会选择到第二,然后第三,然后选项卡到复选框按钮,我会按Enter,行将被添加.然后焦点将返回到添加行按钮,我可以按Enter键重新开始处理.现在,这是一个模态,我失去了一切,除了tabbing.我已经找到了使用 jquery应用焦点的解决方案,但是我已经在网格控制器里面了.

Kendo-ui电网控制器

$scope.mainGridOptions = {
        dataSource: dataSource,pageable: false,toolbar: [{ name: "create",text: "Add Product",}],columns: [
        { field: "product",title: "Product",width: "95px",editor: productEditor },{
            field: "price",title: "Price",format: "{0:c2}",editor: priceEditor
        },{
            field: "sqft",title: "Square Feet",editor: sqftEditor
        },{
            command: [{ name: 'edit',text: { edit: '',update: '',cancel: '' },width: '20px' },{ name: 'destroy',text: '' }],title: ' ',width: '80px'
        }],editable: 'inline'
    };

    function productEditor(container,options) {
        $('<input id="product" name="product" data-bind="value:product" data-productvalidation-msg="Put the Product!" />')
           .appendTo(container)
           .kendoMaskedTextBox({});
        $("#product").focus(function () {
            var input = $(this);
            setTimeout(function () {
                input.select();
            });
        });
    };

    function priceEditor(container,options) {
        $('<input id="price" name="price" data-bind="value:price" data-step="10000" style="" data-productvalidation-msg="Put the Price!"/>')
            .appendTo(container)
            .kendoNumericTextBox({ format: 'c0',min: 0 });
        $("#price").focus(function () {
            var input = $(this);
            setTimeout(function () {
                input.select();
            });
        });
    }

    function sqftEditor(container,options) {
        $('<input id="sqft" name="sqft" data-bind="value:sqft" data-step="500" style="" data-productvalidation-msg="Put the Sqft!"/>')
            .appendTo(container)
            .kendoNumericTextBox({ format: '0',min: 0 });
        $("#sqft").focus(function () {
            var input = $(this);
            setTimeout(function () {
                input.select();
            });
        });
    };

语气

<!-- Grid Modal -->
                    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                        <div class="modal-dialog modal-lg" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <div style="width:100%"><span class="modal-label">My Product Data</span><button style="float:right" class="btn btn-custom waves-effect" data-dismiss="modal"><i class="zmdi zmdi-close"></i></button></div>
                                </div>
                                <div class="modal-body">
                                    <div kendo-grid id="grid" options="mainGridOptions"></div>
                                </div>
                            </div>
                        </div>
                    </div><!--End Grid Modal -->

功能打开模式

$scope.openGrid = function () {
    $('#myModal').modal('show');
};

解决方法

对于 NumericTextBox Kendo-UI控件的API函数,可以通过执行以下伪代码获得焦点:
var numerictextbox = $("#numerictextbox").data("kendoNumericTextBox");
numerictextbox.focus();

所以将它应用到你的代码,它看起来像这样:

var price= $("#price").data("kendoNumericTextBox");
price.focus();

此外,由于您的模态弹出窗口更多的是一个应用程序,我建议切换可访问性属性

role="document"role="application"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


kindeditor4.x代码高亮功能默认使用的是prettify插件,prettify是Google提供的一款源代码语法高亮着色器,它提供一种简单的形式来着色HTML页面上的程序代码,实现方式如下: 首先在编辑器里面插入javascript代码: 确定后会在编辑器插入这样的代码: <pre
这一篇我将介绍如何让kindeditor4.x整合SyntaxHighlighter代码高亮,因为SyntaxHighlighter的应用非常广泛,所以将kindeditor默认的prettify替换为SyntaxHighlighter代码高亮插件 上一篇“让kindeditor显示高亮代码”中已经
js如何实现弹出form提交表单?(图文+视频)
js怎么获取复选框选中的值
js如何实现倒计时跳转页面
如何用js控制图片放大缩小
JS怎么获取当前时间戳
JS如何判断对象是否为数组
JS怎么获取图片当前宽高
JS对象如何转为json格式字符串
JS怎么获取图片原始宽高
怎么在click事件中调用多个js函数
js如何往数组中添加新元素
js如何拆分字符串
JS怎么对数组内元素进行求和
JS如何判断屏幕大小
js怎么解析json数据
js如何实时获取浏览器窗口大小
原生JS实现别踩白块小游戏(五)
原生JS实现别踩白块小游戏(一)