Author Topic: changing array of source data  (Read 6234 times)

argo

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 33
    • View Profile
changing array of source data
« on: August 08, 2013, 05:34:34 pm »
I'm using pqgrid to display a json data set. I'm loading the json data through a separate function and supplying that as the dataModel.data value. I'm using separate filter controls on the page that determine which records should be displayed. Based on the filters the user applies, I'm altering which rows exist in the data and setting a new value for dataModel.length. I then call the "refreshDataAndView" method. The issue is that it works only if the array size gets smaller. For example, I can start with 1500 rows of data, filter to 100 (or any number less than 1500). But as soon as I go back up (say back to 101 rows), I get an error from the pqgrid script saying "unable to get the value of the property 'hidden'': object is null or undefined".

I feel like I'm having a senior moment and forgetting something obvious. Any ideas?

In troubleshooting I've even gone down the path of "destroy"ing the entire pqgrid object, then recreating it with the updated data and it still throws the same error.

argo

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: changing array of source data
« Reply #1 on: August 08, 2013, 05:52:37 pm »
Nevermind, I was having a true senior moment. I forgot to clone the original data array when I retrieved it so every time dataMode.data got fewer rows, the source data was getting smaller too. Fixed with a quick splice(0) when setting the original data value.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: changing array of source data
« Reply #2 on: August 08, 2013, 11:53:07 pm »
Sounds great and don't worry, we all have our senior moments :)