Author Topic: Filtering with local data  (Read 4958 times)

karyn.ulriksen

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 8
    • View Profile
Filtering with local data
« on: January 03, 2014, 02:14:40 am »
*nevermind!*   I figured this one out after much trial and error
« Last Edit: January 03, 2014, 06:51:24 am by karyn.ulriksen »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Filtering with local data
« Reply #1 on: January 03, 2014, 03:08:19 pm »
Did you face any difficulty while implementing filtering with local data.

karyn.ulriksen

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Filtering with local data
« Reply #2 on: January 08, 2014, 04:14:35 am »
All was good until I added the ability to refresh the data.    I the refreshed data view doesn't filter and trying to apply a filter after the data is refreshed results in no filtering.  I can see that the filter object is still being properly created when i log the object to console, but it appears to loose track of the data is suppose to filter... sometimes it appears to resort the data row (not per my sortIndx,  but still ignores the filter.  I want to be able to refresh data (these are statistic bits) with the filters applied.

Some background:

To accomodate your demand for flat array structures, I convert from my heirarchal JSON data structures to dataq in the following format:

        [ {data1a: 'a', data1b: 'b'}, {data2a: 'aa', data2b: 'bb'} ,  {data3a: 'aaa', data3b: 'bbb'} ]

Since these rows expand and contracts depending on whats going on, I set up the initial data structure with a push:  $("#stats_table").data('pqstore').push(data_set);   where, basically, data_set = {data1a: 'a', data1b: 'b'}; 

To refresh this, I remove the datastore, reinitialize it and then reload it:

   $("#stats_table").removeData('pqstore');
   $("#stats_table").data('pqstore',[]);
   loadStats();

Any other method is duplicating the data, but this method breaks the filtering...   Can you provide me some insight as to what needs to happen here? This feature is one of the major reasons I wanted to use this library.
« Last Edit: January 08, 2014, 08:33:36 am by paramquery »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Filtering with local data
« Reply #3 on: January 08, 2014, 08:57:40 am »
Karyn

I understand that you need to refresh data after filtering and you need to re apply filtering after refreshing data which is a simple use case.

But some of your assumptions are incorrect and your data format looks strange.

Code: [Select]
[ {data1a: 'a', data1b: 'b'}, {data2a: 'aa', data2b: 'bb'} ,  {data3a: 'aaa', data3b: 'bbb'} ]

and this is not the right way to assign and remove viewable data to grid.

Code: [Select]
$("#stats_table").removeData('pqstore');
$("#stats_table").data('pqstore',[]);

You have to assign data to grid through dataModel. A call to refreshDataAndView would refresh view as well as reapply filter.
Code: [Select]
$grid.pqGrid( "option", "dataModel.data", data );
$grid.pqGrid( 'refreshDataAndView' );


Could you please post a small but complete example of your code so that I may have a look what's going on. Please also share your requirement of unique statistical data format so that I could help you in best possible way.

« Last Edit: January 08, 2014, 08:28:44 pm by paramquery »