title: knockout js button click select all the checkbox
body: <p>I am using Knockout js for binding, i am binding list of data with checkbox,the data i am fetching and binding to list item including checkbox to all item,now i need to create new button name "select-all" and when i click that button i need to select all the checkbox and i need to get all data from selected checkbox how to achieve this need help..</p>
  
  <pre><code>&lt;div&gt;
  &lt;input type="button" value="Select-All" data-bind="click:SelectAll" /&gt;
  &lt;/div&gt;
  &lt;div  id="List" data-bind="foreach:items"&gt;
  &lt;ul&gt;
  &lt;li&gt;
  &lt;span data-bind="text:userId" style="display:none"&gt;&lt;/span&gt;
  &lt;span style="margin-top: 10px;font-size: 22px;font-weight: bold;padding-left:0px;" data-bind="text:username"&gt;&lt;/span&gt;
  &lt;input  type="checkbox" data-bind="value:userId(),click:$root.toggle" /&gt;                   
  &lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;
  
   //ViewModel
  function userViewModel()
   var self=this;
       {
      function userList(userId, userName)
       {
        var self=this;
       self.userID=ko.observable(userId);
       self.userName=ko.observable(userName);
       self.Selected = ko.observable(false);
       }
     self.toggleAssociation = function (item) {
       //here i am getting the individual selected checkbox Item 
     }
  
   //This part is not working 
    self.SelectAll = function() {
    console.log("in")
   self.items().forEach(function(item) {
      item.Selected(true);
  });
    };
  
     self.items = ko.observableArray();
       self.add = function (userId, userName,){
       self.items.push(new FriendsContact(userId, userName)
     }
  };
  
   //Page Load  
   $(function () {
  var viewModel = new userViewModel();
  ko.applyBindings(viewModel);
  
   //Get the data from database//
   $.ajax({
      type: "GET",
      dataType: "json",
      contentType: 'application/json; charset=utf-8',      
      url: baseUrl + 'xxx/xxx/xxxxx',
      success: function (data) { 
              $.each(data, function (key, value) {
                  viewModel.add(value.userId, value.userName)
              });
      }
  })
  });
  </code></pre>