clarification on getFilteredRows behaviour

75 views
Skip to first unread message

Vikas NV

unread,
Dec 6, 2012, 2:03:21 AM12/6/12
to google-visua...@googlegroups.com
Hi,

I need to understand how the getFilteredRows behaves in this scenario:
  1. apply a getFilteredRows with a numeric min & max for a column that has numeric values
   2. do a setRows from the row indices i get from 1st step (these are applied min & max->min: 10000 & max: Max in that column)
   3. apply a getFilteredRows again with a numeric min & max for a column that has numeric values (on a column other than that i applied in step 1)
   4. do a setRows from the row indices i get from 3rd step (these are applied min & max->min 1.05 & max: Max in that column)

Now i expect that the second getFilteredRows will act on the rows that were there after i did setRows from 2nd step

Am i right? I do not see this behavior though .. i mean even though i applied 1.05 as min for filter in 4th step i see values that that <1.05
But if i apply only the filter in 3rd step first (without any other previously) .. it works fine

What i do for applying filter is this--
  . get column, min & max from user
  . do getFilteredRows & get the row indices
  . then setRows by passing row indices i get from previous step

Thanks,
Vikas

asgallant

unread,
Dec 6, 2012, 2:06:44 PM12/6/12
to google-visua...@googlegroups.com
How this behaves depends on what you are actually filtering.  You need to filter a base data set and then set the rows of a DataView based on that data set.  If you filter the DataView, you can't use the returned rows to set the rows in the DataView again (as the array of rows will contain the row indices in the DataView, not the underlying DataTable).  You would have to do one of three things: 

1) translate the array of DataView row indices into DataTable row indices (via the DataView#getTableRowIndex method), or 
2) create a new DataView based on the current DataView, and set the rows in the new view, or
3) add the new filter to a filter array, and refilter the base DataTable again, using all filters

Method 2 could get rather complicated for an arbitrarily large number of filters.  Method 1 requires more code than method 3, but is potentially more efficient for filtering very large data sets.

This can get complicated for arbitrarily large numbers of filters, though, so I would suggest keeping track of all filters, and filtering the base data using all filters

Vikas NV

unread,
Dec 6, 2012, 9:08:05 PM12/6/12
to google-visua...@googlegroups.com
Thanks Asgallant. I am using method #1
Reply all
Reply to author
Forward
0 new messages