Angular 将焦点设定在kendoui multiselect上
如何在视图初始化(ngAfterViewInit)之后设置kendoui multiselect元素的焦点 在正常输入元素中,我将焦点设置为: HTML: 谢谢你的帮助 查看它们,您可以使用Angular 将焦点设定在kendoui multiselect上,angular,kendo-ui-angular2,Angular,Kendo Ui Angular2,如何在视图初始化(ngAfterViewInit)之后设置kendoui multiselect元素的焦点 在正常输入元素中,我将焦点设置为: HTML: 谢谢你的帮助 查看它们,您可以使用open输入 @Component({ selector: 'tester', template: ` <kendo-multiselect #setFocus [data]="items"></kendo-multiselect> ` }) c
open
输入
@Component({
selector: 'tester',
template: `
<kendo-multiselect #setFocus [data]="items"></kendo-multiselect>
`
})
class TesterComponent {
@ViewChild('setFocus')
focusElement: MultiSelectComponent;
ngAfterViewInit() {
this.focusElement.open = true;
}
}
@组件({
选择器:“测试器”,
模板:`
`
})
类测试组件{
@ViewChild('setFocus')
聚焦元件:多选元件;
ngAfterViewInit(){
this.focusElement.open=true;
}
}
例如,您可以通过使用
[open]
作为模板输入来切换此选项。您可以随时查看html控件的呈现方式,并可以使用
let el = this.focusElement.nativeElement;
if (el.className.indexOf("k-multiselect") != -1) { // kendo multiselect
el.children[0].children[1].children[0].focus();
}
或者使用jquery
let el = this.focusElement.nativeElement;
$(el).find(".k-input").focus();
直到剑道正确地执行此操作。我将此用于自动完成,也许它可以帮助: 模板:
<kendo-autocomplete #customerIdCtl ...
正在计划改进focus | blur支持-。在实现之前,您需要在此线程中使用一些给定的建议。谢谢您的回答!我将等待焦点/模糊支持。
let el = this.focusElement.nativeElement;
$(el).find(".k-input").focus();
<kendo-autocomplete #customerIdCtl ...
@ViewChild('customerIdCtl') customerIdCtl
ngAfterViewInit() {
setTimeout(() => {
const el: any = document.querySelectorAll(`#${this.customerIdCtl.focusableId}`)[0]
el.focus()
})
}