0

I have created a plunker to show issue here

If you click on the "Display rows with missing data" link then all is well and it filters to show row with misssing data. However, if you then click on "show all data" it will not show the rest of the data again? How to resolve this?

Code:

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";

      }
};

1 Answer 1

3

You have to use angular.copy to save data before modifying it:

vm.savedResourceGridResources = angular.copy(vm.resourceGridResources);

Working plunker.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.