Tuesday, 1 November 2011

Multiselector checkAll selects all options instead of filtered list


I am using multiselector and whenever I try to select all filtered result by clicking checkAll then it selects all options not only filter list but all.
Example: I have list like
abc1, abc2, abc3, xyz1, xyz2
and I filtered by “abc” text and I got three result abc1, abc2 and abc3
Then I clicked on checkAll link it shows it selected 3 options but it is selecting all 6 options, for this problem I have done general method and it is working fine
Added this function call in that html file
<script>
$(document).ready(function() {
checkAllCorrection(‘#selctboxid’);
});
</script>
General method in application.js file
function checkAllCorrection(fieldName){
$(fieldName).bind(“multiselectcheckall”, function(event, ui){
    var checkedValueList = [];
    $(fieldName).multiselect(“getChecked”).each(function(){
         checkedValueList.push(this.value);
     });
    $(fieldName).multiselect(“refresh”);
    $(fieldName).multiselect(‘widget’).find(“:checkbox”).each(
          function(){
               if(checkedValueList.indexOf(this.value) == -1
&& this.checked)        this.click();
           }
    );
    });
}

No comments:

Post a Comment