# Power Table - filtering by hidden rows

**URL:** <https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967>\
**Category:** Ignition\
**Tags:** ignition80, scripting\
**Created:** [April 15, 2020, 9:15pm UTC](https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967 "2020-04-15T21:15:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dansadowski](https://avatars.discourse-cdn.com/v4/letter/d/d6d6ee/32.png) [@dansadowski](https://forum.inductiveautomation.com/u/dansadowski)\
**Post date:** [April 15, 2020, 9:15pm UTC](https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967/1 "2020-04-15T21:15:39Z")

</div>

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:

```python
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

---

<div class="post-metadata">

**Author:** ![dansadowski](https://avatars.discourse-cdn.com/v4/letter/d/d6d6ee/32.png) [@dansadowski](https://forum.inductiveautomation.com/u/dansadowski)\
**Post date:** [May 4, 2020, 5:25pm UTC](https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967/2 "2020-05-04T17:25:48Z")

</div>

Bump - still looking for some input on this.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 4, 2020, 8:38pm UTC](https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967/3 "2020-05-04T20:38:05Z")

</div>

> [@dansadowski](#):
>
> `model = self.getTable().getModel().getActualModel()`

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:

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

```

---

<div class="post-metadata">

**Author:** ![dansadowski](https://avatars.discourse-cdn.com/v4/letter/d/d6d6ee/32.png) [@dansadowski](https://forum.inductiveautomation.com/u/dansadowski)\
**Post date:** [May 4, 2020, 9:55pm UTC](https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967/4 "2020-05-04T21:55:18Z")

</div>

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](https://forum.inductiveautomation.com/uploads/short-url/zPm5KD10b8cjqSSnzgyc1EicM0I.zip) (10.7 KB)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 4, 2020, 11:11pm UTC](https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967/5 "2020-05-04T23:11:17Z")

</div>

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`](http://www.jidesoft.com/javadoc/com/jidesoft/grid/AbstractTableFilter.html), which you would call as `self.getRowIndex()`/`self.rowIndex` in `isValueFiltered():`

---

<div class="post-metadata">

**Author:** ![renzoc](https://avatars.discourse-cdn.com/v4/letter/r/bcef8e/32.png) [@renzoc](https://forum.inductiveautomation.com/u/renzoc)\
**Post date:** [November 5, 2021, 12:45am UTC](https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967/6 "2021-11-05T00:45:29Z")

</div>

Hi, is this doable in a dropdown? Thanks.

---

<div class="post-metadata">

**Author:** ![Tom\_Poswell](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@Tom\_Poswell](https://forum.inductiveautomation.com/u/Tom_Poswell)\
**Post date:** [December 17, 2021, 2:46pm UTC](https://forum.inductiveautomation.com/t/power-table-filtering-by-hidden-rows/33967/7 "2021-12-17T14:46:04Z")

</div>

Hello , Excuse me, I am noob programming with python and Igniton, I want to prove your code but i dont know where I have to insert it. Should I insert this code in PropertyChange, configureCell or isCellEditable?

In My project I want to filter a “Power Table” using a “Text Field”  
 ![qu](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/6/860ac1482b4c5360fa644a4693ffbf002dceca28.jpeg)
