title: Apply filter to returned results
body: <p>I have a <code>Customer</code> model like so (simplified):</p>
  
  <pre><code>public int CustomerAcc { get; set; }
  public string Name { get; set; }
  public int Blocked { get; set; }
  </code></pre>
  
  <p><code>Blocked</code> has 3 possible values: 0, 1, 2. 0 means okay, 1 means customer is warned, 2 means customer is blocked.</p>
  
  <p>I then have a knockout viewModel like so:</p>
  
  <pre><code>function SearchCustomerViewModel() {
      var self = this;
      self.custTerm = ko.observable('');
      self.customers = ko.observableArray([]);
      self.excludeClosedAccs = ko.observable(true);
  
      self.search = function () {
          $.ajax({
              url: "/api/SearchCustomers",
              data: { id: self.custTerm },
              type: "GET",
              success: function (data) {
                  self.customers(data);
              }
          });
      }
  }
  
  $(document).ready(function () {
      var viewModel = new SearchCustomerViewModel();
      ko.applyBindings(viewModel);
      $("#btnSearch").click({ handler: viewModel.search });
  });
  </code></pre>
  
  <p>This provides a simple search api which searches my customer repository. I have a property called <code>excludeClosedAccs</code> which I have set as true by default, which I would like to exclude any accounts in my view which have a <code>Blocked</code> equal to 2. This is a checkbox on my view, which when unticked, will include them in my results. Here is my View:</p>
  
  <pre><code>&lt;div id="body"&gt;
      &lt;h1&gt;Customer Search&lt;/h1&gt;
  
      &lt;div&gt;
          Search:&lt;input type="text" data-bind="value: custTerm" /&gt;
  
          &lt;input type="button" id='btnSearch' title="Search" value="Search" /&gt;
      &lt;/div&gt;
  
      &lt;div data-bind="visible: customers().length &gt; 0"&gt;
          &lt;span data-bind="text: customers().length"&gt;&lt;/span&gt;
          customers found.
          &lt;label&gt;Exclude Closed Accounts: &lt;input data-bind="checked: excludeClosedAccs" type="checkbox"/&gt;&lt;/label&gt;
      &lt;/div&gt;
  
      &lt;div id="results-container" data-bind="template: { name: 'customer-results', foreach: customers }"&gt;&lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;script type="text/html" id="customer-results"&gt;
      &lt;div&gt;
          &lt;h6 data-bind="text: CustomerAcc"&gt;&lt;/h6&gt;
          &lt;p&gt;Company Name: &lt;span data-bind="text: Name"&gt;&lt;/span&gt;&lt;/p&gt;
          &lt;!-- ko if: Blocked &gt; 0 --&gt;
          &lt;p&gt;Blocked: &lt;span data-bind="text: Blocked"&gt;&lt;/span&gt;&lt;/p&gt;
          &lt;!-- /ko --&gt;
      &lt;/div&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Is it possible to apply a filter on my <code>self.customers</code> array to do what I wish or do I have to make a seperate request, one to exclude blocked accounts and one which includes them?</p>