Script filtering on Power Table

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

Knew I had this lying around somewhere:

1 Like

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… :confused:

From getting the base classes via script, I know that this class derives from the following:
image

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:

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.

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

# 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!

1 Like

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