在 kendo 多选中隐藏建议中的非活动项目

hiding the Inactive Items form the Suggestions in kendo Multiselect

我的应用程序中有一个 multiselect。我有一个要求,我们不应该在 multi-select 下拉建议列表中显示非活动用户。我们在模型中有旗帜。所以需要知道我们可以使用该标志过滤下拉列表。请找到随附的屏幕截图以获取想法。

我们可以使用该标志过滤 ajax 调用中的数据。但是需要获取已经 select 的非活跃用户的名称。所以我试图仅从建议列表中隐藏非活动用户。

所以需要显示selected的非活跃用户,但是从建议中需要隐藏非活跃用户。

不确定这是否是最好的方法,但您可以尝试在 open event and removing it in close 事件中对数据源应用过滤器:

$("#multiselect").kendoMultiSelect({
  dataSource: {
    data: [{Name: "test 1", Active: true, Id: 1},
          {Name: "test 2", Active: true, Id: 2},
          {Name: "test 3", Active: false, Id: 3},
          {Name: "test 4", Active: true, Id: 4},
          {Name: "test 5", Active: false, Id: 5}]
  },
  value: [1, 3],
  dataTextField: "Name",
  dataValueField: "Id",
  filter: "startswith",
  open: function(e) {
    this.dataSource.filter({ field: "Active", operator: "eq", value: "true" });
  },
  close: function() {
    this.dataSource.filter(null);
  }
});

Demo