我创建了一个插件来显示问题here
如果单击“显示缺少数据的行”链接,那么一切都很好,它会进行过滤以显示缺少数据的行。但是,如果您随后单击“显示所有数据”,将不会再次显示其余数据?如何解决呢?
码:
vm.applyMissingValuesFilter = function (linktext) {
if (linktext === "Display rows with missing data") {
vm.savedResourceGridResources = vm.resourceGridResources;
var results = [];
var temp = vm.resourceGridResources.Resources;
for (var i = 0; i < temp.length; i++) {
for (var j = 0; j < temp[i].Resources.length; j++) {
if (!temp[i].Resources[j].Value) {
if (results.indexOf(temp[i]) === -1) {
results.push(temp[i]);
}
}
}
}
vm.resourceGridResources.Resources = results;
vm.missingValuesButtonText = "Show all data";
}
else if (linktext === "Show all data") {
// should reset the resource values here to redisplay original data?
vm.resourceGridResources = vm.savedResourceGridResources;
vm.missingValuesButtonText = "Display rows with missing data";
}
};
最佳答案
在修改数据之前,必须使用angular.copy
保存数据:vm.savedResourceGridResources = angular.copy(vm.resourceGridResources);
Working plunker。