Setting focus on first field of a pop up edit form in kendo grid

与世无争的帅哥 提交于 2019-12-08 06:45:53

问题


I have a kendo grid in pop up edit mode. First field of the pop up form is auto complete widget. I want to give focus on it whenever the pop up form pops up. I tried to do this in different way as

$("#grid").kendoGrid({ 
    editor: 
        function(container, options) { 
            $('<input id="item_code_focus" name="' + options.field + '"/>')
                .appendTo(container)
                .kendoAutoComplete({ 
                    -----
                    -----
            }).focus()
        }
});

But it is not working. Please help me?...


回答1:


You could try and use the edit event of the Grid.

    edit:function(e){   
         e.container.data('kendoWindow').bind('activate',function(e){
            $('#autocomplete').focus();
         })

    },

EDIT: Actually you should use the Window activate event to call focus. Here is example. @OnaBai calling focus when using the edit does not make the input to lose focus - actually the animation causes this behavior.



来源:https://stackoverflow.com/questions/14290320/setting-focus-on-first-field-of-a-pop-up-edit-form-in-kendo-grid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!