问题
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