【问题标题】:angular2-multiselect-dropdown not disabling select all filtered resultangular2-multiselect-dropdown 不禁用选择所有过滤结果
【发布时间】:2020-12-28 17:50:14
【问题描述】:

HTML

<angular2-multiselect id="multi_select" name="multiselect" required
    [disabled]="true"
    [(ngModel)]="selected"
    [data]="list" 
    (onSelect)="call()"
    (onDeSelect)="call()" [settings]="dropDownSetting" 
    (onSelectAll)="call()" 
    (onDeSelectAll)="call()">
     <span class="glyphicon glyphicon-filter"></span>
</angular2-multiselect>

TS

mySettings = {
        singleSelection: false,
        text: '',
        selectAllText: 'Select All',
        unSelectAllText: 'UnSelect All',
        enableSearchFilter: true,
        badgeShowLimit: 1,
    };

我无法在“选择所有过滤结果”中应用函数调用或无法禁用它。但同样适用于“全选”。

【问题讨论】:

  • 请编辑您的问题并将代码放在内容中,而不是在 cmets 中
  • html 代码已经在内容中,这是格式问题。
  • 我没有看到您的 TS mySettings 变量和您的 HTML 代码之间的链接。我怀疑您想用“mySettings”替换 HTML 中的“dropDownSetting”变量?
  • 是的。它实际上是我的设置。

标签: angular


【解决方案1】:

在你的下拉设置中:

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

单选:真,

【讨论】:

    【解决方案2】:

    您的问题是“当我在AngularJS Dropdown Multiselect 中“全选”时如何禁用禁用项目的选择?

    您必须修改 angularjs-dropdown-multiselect.min.js 文件(我使用缩小文件),您将下载该文件以使用此...您将这些...称为什么东西。

    selectAll() 函数必须更改为仅选择非禁用项。

                function selectAll() {
                   $scope.deselectAll(true);
                   $scope.externalEvents.onSelectAll();
    
                   var searchResult = $filter('filter')($scope.options, $scope.getFilter($scope.input.searchFilter));
                   var filteredResult = searchResult.filter(function (option) {
                      return !option.disabled;
                   });
    
                   angular.forEach(filteredResult, function(value) {
                      $scope.setSelectedItem(value, true, false);
                   });
                   $scope.externalEvents.onSelectionChanged();
                   $scope.selectedGroup = null;
               }
    

    来源:https://github.com/dotansimha/angularjs-dropdown-multiselect/issues/361

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-21
      • 2014-07-19
      • 2023-04-11
      • 1970-01-01
      相关资源
      最近更新 更多