Power Table - filtering by hidden rows

Is it possible to filter a power table using values in a hidden column?

I have the following in a custom method on a Power Table and it seems to work fine when the filter columns are not hidden in the Power Table’s Dataset:

def filterRowsByColumnValue(self, column_name):
	model = self.getTable().getModel().getActualModel()  
	column_count = model.getColumnCount()
	i = 0
	#find the index of the column by column name
	while i < column_count:
		name = model.getColumnName(i)
		if name == column:
			column_index = i
			break
		i=i+1
	#remove any previous filters
	model.clearFilters()
	from com.jidesoft.grid import SingleValueFilter
	#create the filter
	class newFilter(SingleValueFilter):
		def isValueFiltered(self, value):
			if value == 0: #if this is a row that's a zero it should be filtered, so return true
				return True
			return False
	model.addFilter(column_index, newFilter())
	model.setFiltersApplied(True)
	model.refresh()

However, as soon as I mark those control columns as hidden (it’s not something that I want the operators to see), the iteration of column names no longer finds an index for the column that I want to filter by.

I’m assuming that hidden columns aren’t passed into the underlying model, is that an accurate assumption, or is there a different way to get at and filter by hidden columns in the model?

Thanks in advance,
Dan

Bump - still looking for some input on this.

That’s the “source” of the problem, but it should be easy enough to work around. When you’re creating your filter, couldn’t you still reference the actual dataset (rather than the ‘view model’)? If you need to adjust column offsets back and forth, the table has helper methods:

    public int columnIndexToModelIndex(int columnIndex);
    public int columnIndexToDatasetIndex(int columnIndex);
    public int datasetIndexToColumnIndex(int columnIndex);

I’m not sure - I think that I have to apply the filter to the model at the appropriate index:

   model.addFilter(column_index, newFilter())

Once I hide my control column, that column doesn’t appear to be available to the underlying model. Take a look at the attached project example.

The top set of power tables are working as I expected it. In the bottom set, the column is hidden and attempting to hide a row throws an error.

ShowHideExample_2020-05-04_1446.zip (10.7 KB)

You could apply the filter to a different column (that does exist), and use your newFilter class’ getters to reference the appropriate row; see getRowIndex() on AbstractTableFilter, which you would call as self.getRowIndex()/self.rowIndex in isValueFiltered():