Array filter is availing an observable-array
and returns true if array of items are match otherwise returns false.
For example filter an observable array using computed binding as given below.
var filterSelections = ko.computed(function (Text) {
try {
var filterText = Text.toLowerCase();
if (!filterText) {
return selectionList();
}
else {
if (selectionList().length > 0) {
return ko.utils.arrayFilter(selectionList(), function (item) {
if (item.SelectionLabel.toLowerCase().indexOf(filterText) > -1 || item.SelectionDescription.toLowerCase().indexOf(filterText) > -1) {
return true;
}
else {
return false;
}
});
}
}
}
catch (ex) {
logExceptions(ex);
}
});