'getting total size of ArrayDataProvider
I am using a knockout computed function to update a list with a filter based on inputs from user. This list has some predefined data, and when the filter is applied, I want to know the size of the resulting filtered list. I tried the following, but it doesn't print updated filtered data count.
this.dataprovider = ko.computed(function () {
const filterRegEx = new RegExp(self.filter(), 'i');
const filterCriterion = {
op: '$or',
criteria: [
{
op: '$regex',
value: {
name: filterRegEx,
},
},
{
op: '$regex',
value: {
dept: filterRegEx,
},
},
],
};
const arrayDataProvider = new ArrayDataProvider(self.data(), {
keyAttributes: 'deptid',
});
const listDataProviderView = new ListDataProviderView(arrayDataProvider, {
filterCriterion: filterCriterion,
});
listDataProviderView.getTotalSize().then(function (totalCount) {
self.filteredCount('Total rows: ' + totalCount);
});
return listDataProviderView;
}, this);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|