# Filter Values in MultiSelects Sharing the Same Data

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Progress® Kendo UI® MultiSelect for jQuery</td>
 </tr>
 <tr>
  <td>Operating System</td>
  <td>Windows 10 64bit</td>
 </tr>
 <tr>
  <td>Visual Studio Version</td>
  <td>Visual Studio 2017</td>
 </tr>
 <tr>
  <td>Preferred Language</td>
  <td>JavaScript</td>
 </tr>
</table>

## Description

How can I filter the values of two Kendo UI widgets, which share the same data, based on user selection?

## Solution

The following example demonstrates how to achieve the desired scenario.

```dojo
    <select id="multiselect1">
    </select>
    <br />
    <select id="multiselect2">
    </select>
    <script>
      var initialData = [{id:1, name: "item1"}, {id:2, name: "item2"}, {id:3, name: "item3"}];

      function distinctValues(values) {
        return initialData.filter(function(current){
          return values.filter(function(initial){
            return initial == current.id
          }).length == 0
        });
      }

      $("#multiselect1").kendoMultiSelect({
        dataSource: initialData,
        dataTextField: "name",
        dataValueField: "id",
        change: function() {
          var ms2 = $("#multiselect2").getKendoMultiSelect();
          var values = distinctValues(this.value());
          ms2.dataSource.data(values);
        }
      });

      $("#multiselect2").kendoMultiSelect({
        dataTextField: "name",
        dataValueField: "id",
        dataSource: initialData,
        change: function() {
          var ms1 = $("#multiselect1").getKendoMultiSelect();
					var values = distinctValues(this.value());
          ms1.dataSource.data(values);
        }
      });
    </script>
```

## See Also

* [MultiSelect JavaScript API Reference](https://www.telerik.com/kendo-jquery-ui/documentation/api/ui/multiselect)
* [Cascade from DropDownList](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/cascade-from-ddl)
* [Preselect Items Using MVVM Binding](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/preselect-items-using-mvvm)
* [Select All Values with Single Selection](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/select-all-values-with-one-selection)
* [Use MultiSelect with Bootstrap Modal Window](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/using-widget-with-boostrap-modal)
* [Wire Blur Event of the Filter Input](https://www.telerik.com/kendo-jquery-ui/documentation/knowledge-base/wire-blur-event-of-filter-input)
