title: kendo grid : filtering on an array object
body: <p>I want to filter on a kendo grid that it's model has list of objects.</p>
  
  <p>My filter is not working on a list of Contacts:</p>
  
  <p>Here's my javascript code:</p>
  
  <pre><code>var typeFilter;
  var contactsFilter;
  var datesFilter;
  var ByFiler;
  var zeroFilter = {
      field: "ID",
      operator: "eq",
      value: 0
  };
  
  function filterOnMultiSelectContacts(e) {
  
      var filters;
      for (var i = 0; i &lt; $('#ContactsDropDownFilter').data("kendoMultiSelect").dataItems().length; i++)
      {
          filters =[
                      {
                          field: "Contacts.ContactID",
                          operator: "eq",
                          value: Number($('#ContactsDropDownFilter').data("kendoMultiSelect").dataItems()[i].ContactID)
                      },
                          zeroFilter
          ]
      }
  
      contactsFilter = {
          logic: "or",
          filters: filters
      };
      applyFilters();
  }
  
  function TypeChanged(e) {
      var type = $("#SelectedType").val();
      var value = Number(type);
  
      if (value === -1) {
          typeFilter = null;
      }
      else {
          typeFilter = {
              logic: "or",
              filters: [
                  {
                      field: "Type",
                      operator: "eq",
                      value: value
                  },
                  zeroFilter
              ]
          };
      }
      applyFilters();
  }
  
  
  function applyFilters() {
      var ds = $("#Grid").data("kendoGrid").dataSource;
      var filters = [];
  
      if (typeFilter) filters.push(typeFilter);
      if (contactsFilter) filters.push(contactsFilter);
      if (datesFilter) filters.push(datesFilter);
      ds.filter(filters);
  }
  </code></pre>
  
  <p>The filter on my date and on my type is working fine because the fields (model) are not an array. On the other hand, my <code>filterOnMultiSelectContacts()</code> function is not working correctly. My guess that my mistake is this line <code>field: "Contacts.ContactID"</code>. This line is working fine by guetting the correct ContactID :</p>
  
  <p><code>Number($('#ContactsDropDownFilter').data("kendoMultiSelect").dataItems()[i].ContactID)</code></p>
  
  <p>By the way here's my razor datasource for the grid:</p>
  
  <pre><code>    .DataSource(dataSource =&gt; dataSource
      .Ajax()
      .ServerOperation(false)
      .Events(e =&gt; e.Sync("SyncLogEventGrid"))
      .Model(m =&gt;
      {
          m.Id(t =&gt; t.LogEventID);
          m.Field(u =&gt; u.CreatedByContact).DefaultValue(UserHelper.GetCurrentUserContact(Request.RequestContext));
          m.Field(u =&gt; u.CreatedBy).DefaultValue(UserHelper.GetCurrentUserContact(Request.RequestContext).ContactID);
          m.Field(u =&gt; u.Contacts).DefaultValue(new List&lt;ContactModel&gt;());
          m.Field(u =&gt; u.LogEventAttachments).DefaultValue(new List&lt;LogEventAttachmentModel&gt;());
      })
      )
  </code></pre>
  
  <h3>EDIT</h3>
  
  <p>I added in my model ContactIds which contains the Ids of the contacts (not the whole object). I came up with this but it's still not working...</p>
  
  <pre><code>function filterOnMultiSelectContacts(e) {
      contactsFilter = null;
      var ContactIdsList = new Array();
      for (var i = 0; i &lt; $('#LogEventContactsDropDownFilter').val().length; i++)
      {
          ContactIdsList.push(Number($('#LogEventContactsDropDownFilter').val()[i]));
      }
  
      var filters;
      if ($('#LogEventContactsDropDownFilter').data("kendoMultiSelect").dataItems().length &gt; 0) {
          filters = [
                      {
                          field: "ContactIDs",
                          operator: "eq",
                          value: ContactIdsList
                      }
                      ,
                      zeroFilter
          ];
          contactsFilter = {
              logic: "or",
              filters: filters
          };
      }
      else
      {
          contactsFilter = null;
      }
      applyFilters();
  }   
  </code></pre>