没有数据时,角度剑道组合框无法隐藏

问题描述

我正在使用 angular 和 kendo,我使用 kendo 组合框将一些值显示here

我想在没有数据匹配时隐藏弹出窗口,但我不能这样做。

请帮帮我。

解决方法

[combobox.toggle()][1] 为零且 data.length 为 false 时,您必须在过滤器函数中使用 combobox.isOpen

模板

 <div class="example-wrapper">
          <kendo-combobox
            #combo
              [data]="data"
              [textField]="'text'"
              [valueField]="'value'"
              [filterable]="true"
              (filterChange)="handleFilter($event)"
              [placeholder]="'T-shirt size'"
          >
          <ng-template kendoComboBoxNoDataTemplate>
            No data found!
          </ng-template>
          </kendo-combobox>
      </div>

组件

export class AppComponent {
  @ViewChild('combo') combo:ComboBoxComponent

    public source: Array<{ text: string,value: number }> = [
        { text: 'Small',value: 1 },{ text: 'Medium',value: 2 },{ text: 'Large',value: 3 }
    ];

    public data: Array<{ text: string,value: number }>;

    constructor() {
        this.data = this.source.slice();
    }

    handleFilter(value) {
        this.data = this.source.filter((s) => s.text.toLowerCase().indexOf(value.toLowerCase()) !== -1);

      if(this.data.length == 0 && this.combo.isOpen){
    this.combo.toggle()
  }
    }
}

this is full example

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...