3

I have a multiselect in our application. I have a requirement where we should not show the Inactive users in the multi-select dropdown suggestions list. We have the flag in the model. So need to know we can filter the dropdown using that flag. Please find the attached screenshot to get the Idea.

We can filter the data in the ajax call using that flag. But need to get the Names of the already selected Inactive users. So I am trying to hide the Inactive users from the suggestions list only.

So need to show the selected Inactive users, but from the suggestions need to hide inactive users. enter image description here

DontVoteMeDown
  • 21,122
  • 10
  • 69
  • 105
Nalluri
  • 101
  • 1
  • 16
  • It is a bit complicated....why? What if you unselect inactive user? Is he shown in dropdown list or do you need to hide him too? If so, then combination of filters and multiselect events is needed. – dev_in_progress Oct 02 '17 at 09:09
  • Yeah we have to hide him if we unselect him. Main goal is to hide the Inactive users from the dropdown suggestions and show the name if he is already selected. – Nalluri Oct 02 '17 at 13:46

1 Answers1

5

Not sure if this is the best way, but you can try applying a filter on the dataSource in open event and removing it in close event:

$("#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

DontVoteMeDown
  • 21,122
  • 10
  • 69
  • 105