dimanche 30 août 2015

Based on the result of the observable array make the checkbox gets selected

I got struck with the checkbox bind using knockout js. I use two observable arrays. First observable array is used to display all the student details value with the checkbox in the view. In the 2nd observable array I obtain some values filtered that need to be checked(true) dynamically in the view where I have already displayed the checkbox with the whole value. My html code is,

  <div class="col-lg-10" style="white-space:pre">
                                <div class="checkbox-inline" data-bind="foreach: $root.Studentdetails">
                                    <input type="checkbox" data-bind="checkedValue: $data,value:id(), checked: $root.associatedItemIds, click: $root.toggleAssociation" />
                                    <span data-bind="text: '&nbsp;' + Name()"></span>
                                </div>
                            </div>

And this is the way i approach to gets the checkbox selecetd,

     self.associatedItemIds=ko.obsearvablearray();   
     self.associatedItemIds.push(response.CheckStudents);




Aucun commentaire:

Enregistrer un commentaire