# Script filtering on Power Table

**URL:** <https://forum.inductiveautomation.com/t/script-filtering-on-power-table/23673>\
**Category:** Ignition\
**Created:** [March 27, 2019, 11:49pm UTC](https://forum.inductiveautomation.com/t/script-filtering-on-power-table/23673 "2019-03-27T23:49:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 27, 2019, 11:49pm UTC](https://forum.inductiveautomation.com/t/script-filtering-on-power-table/23673/1 "2019-03-27T23:49:19Z")

</div>

Am I able to script the filtering functionality on a power table? I have a datasource (Sepasoft) that can’t be manipulated, and I would like to remove rows on condition. I can do this manually in runtime, but I’d like to be able to have the table load with this filter in place.

Thanks

---

<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:** [March 27, 2019, 11:59pm UTC](https://forum.inductiveautomation.com/t/script-filtering-on-power-table/23673/2 "2019-03-27T23:59:30Z")

</div>

Knew I had this lying around somewhere:

> [@Programmatically-applied PowerTable Filters](http://forum.inductiveautomation.com/t/programmatically-applied-powertable-filters/15495/2):
>
> model = self.getTable().getModel().getActualModel() from com.jidesoft.grid import SingleValueFilter class newFilter(SingleValueFilter): def isValueFiltered(self, value): return True if value == target.data.getValueAt(row, 4) else False model.addFilter(3, newFilter()) model.setFiltersApplied(True) model.refresh() I’ve used this code before to successfully apply a filter (shows the filter icon in the table header correctly), and it also allows it to be removed by select…

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 29, 2019, 6:07am UTC](https://forum.inductiveautomation.com/t/script-filtering-on-power-table/23673/3 "2019-03-29T06:07:45Z")

</div>

Thanks Paul.  
However next question, and I know this is out of your ‘jurisdiction’… but say this wasn’t a power table, but was actually a Sepasoft model, specifically the PMIDowntimeTable class: do you know how I would apply the same thing to this? I can’t find the javadoc for their modules which is a bit frustrating… 😕

From getting the base classes via script, I know that this class derives from the following:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/67b6c4f66083ca83333088af798db1a256da9e76.png)

---

<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:** [March 29, 2019, 2:29pm UTC](https://forum.inductiveautomation.com/t/script-filtering-on-power-table/23673/4 "2019-03-29T14:29:40Z")

</div>

Well, the top-level class is a unique class that extends a basic ‘panel’ - that means the actual component you interact with is almost certainly composed of various underlying objects. If you’re lucky, one of those will be a Jidetable, and the code I linked will still work, you’ll just have to inject it into the right reference. Try dumping all of the components inside of the ‘PMIDowntimeTable’ using something like this:

```auto
def recurse(component, indent = ''):
    l = component.getComponents()
    for index, c in enumerate(l):
        print "%s %s %s" % (indent, index, c)
        recurse(c, indent + '\t')

```

If one of them is a Jidetable, you’re golden - just need to find it (via chained `getComponent(<index>)` calls, then apply the code from above. If not, then you’re in for more trouble.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [March 29, 2019, 11:35pm UTC](https://forum.inductiveautomation.com/t/script-filtering-on-power-table/23673/5 "2019-03-29T23:35:36Z")

</div>

Genius! I’ll hold onto that function, very handy!  
Got it, there’s a power table embedded into the component 🙂

```auto
# add to Sepasoft OEE Downtime Table 'initialise' extension function:
def setFilter(self, col, target):
	model = self.getTable().getModel().getActualModel()
	model.clearFilters()
	from com.jidesoft.grid import SingleValueFilter
	class newFilter(SingleValueFilter):
		def isValueFiltered(self, value):
			# hide the row if the condition below is true
			return bool( value < target )
	model.addFilter(col, newFilter())
	model.setFiltersApplied(True)
	model.refresh()

# get the PMIAdvancedTable component
table = self.getComponent(0).getComponent(1).getComponent(0).getComponent(3).getComponent(0)
setFilter(table, 7, 1) #col 7 = 'Duration column'. Hide durations less than 1s

```

Thanks a bunch!

---

<div class="post-metadata">

**Author:** ![nelson.hurtado](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nelson.hurtado/32/18950_2.png) [@nelson.hurtado](https://forum.inductiveautomation.com/u/nelson.hurtado)\
**Post date:** [September 23, 2021, 12:15am UTC](https://forum.inductiveautomation.com/t/script-filtering-on-power-table/23673/6 "2021-09-23T00:15:26Z")

</div>

I have and power table with a time data col, user col, and description col. I’m using EDGE and I need to filter the time column between choose dates previously! Anybody Can help me to do that, because I used the last script but it is not working
