简体   繁体   English

如何显示 SearchFilter 文本框,即使 Angular Multiselect Dropdown 中没有加载数据

[英]How to show SearchFilter textbox,even there is no data loaded in Angular Multiselect Dropdown

Angular version : 8角度版本:8

ng-multiselect-dropdown version: ^0.2.10 ng-multiselect-dropdown 版本:^0.2.10

In my case, User to be able to start typing in the search field to dynamically load results into the dropdown.在我的情况下,用户能够开始在搜索字段中输入以将结果动态加载到下拉列表中。 But In ng-multiselect-dropdown searchbox to be visible at least one row of data is required.但是在 ng-multiselect-dropdown 搜索框中要可见,至少需要一行数据。 Is there any way to show the search filter always,regardless of whether data is available.无论数据是否可用,有没有办法始终显示搜索过滤器。

this.dropdownList = [];

  this.dropdownSettings= {
  singleSelection: false,
  idField: 'item_id',
  textField: 'item_text',
  selectAllText: 'Select All',
  unSelectAllText: 'UnSelect All',
  itemsShowLimit: 3,
  allowSearchFilter: true
};

enter image description here在此处输入图片说明

I am late to answer, but this can be useful if someone gets the same question again.我回答晚了,但是如果有人再次遇到同样的问题,这会很有用。 Add allowRemoteDataSearch:true to your dropdown options.allowRemoteDataSearch:true添加到您的下拉选项中。

You can refer this thread你可以参考这个线程

https://github.com/NileshPatel17/ng-multiselect-dropdown/issues/182 https://github.com/NileshPatel17/ng-multiselect-dropdown/issues/182

I would have placed an entry 'no data available' when there are no result and remove when it is not necessary.我会在没有结果时放置一个条目“无可用数据”,并在不需要时删除。 Do you think you already use this: onFilterChange ?你认为你已经使用了这个: onFilterChange ?

dropdownList = [];

onFilterChange(data) => { // basic
    const defaultOption = {item_id: -1, item_text: ‘no data available’}
    if(this.dropdownList.length > 1) {
        this.dropdownList.shift();
        this.dropdownSetting.defaultOpen = false;
    } else {
        this.dropdownList.push(defaultOption);
        // leaving the drop down open
        this.dropdownSetting.defaultOpen = true;
    }
}

As me I would have finish the US using noDataAvailablePlaceholderText as mentioned in the doc.和我一样,我会使用文档中提到的 noDataAvailablePlaceholderText 完成美国。 It may not work :)它可能不起作用:)

hope it works for your version希望它适用于您的版本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM