I have a few Vision Power Tables in an application. The client asked if I could make sorts and filters applied during runtime persist when they navigate away from the screen and return. Could implement this with a change script on the viewDataset property that writes the current sort and filter to client tags and use the initialize extension function to load the sort and filter. However, I am not sure how to get and set the currently applied runtime sort and filter information with Python/Jython. Can anyone give me some sample code for this? Thanks.
Simplest possible solution first: if you set the window's cache policy to Always, does it persist your runtime settings within the live client?
I haven't seen anyone do this, but it should be possible. You'll have to dig into the sparse documentation of the JideTable:
Please share your solution....
Some possible prior art:
Window cache policy works great for making filters persistent but doesn't appear to work for sorts, even if I remove binding on table data. Linked forum post did not appear to provide a way to extract currently applied sort order, although it looks like it would work to set sort order. Filters was probably the more important of the two to the client. Don't know if I have the time or inclination to go down that particular Jython rabbit trail, but if someone knows the answer, I'd be curious. Thanks for the info.
In the power table, you can get the column sort information directly from the table model in this way on the propertyChange event handler:
if event.propertyName == 'viewDataset':
table = event.source.table
model = table.model
sortingColumns = model.sortingColumns
if sortingColumns:
sortedColumn = sortingColumns[0].column
isAscending = sortingColumns[0].ascending
else:
sortedColumn = None
isAscending = None
# Store this integer and bool somewhere... client tag?
print sortedColumn, isAscending
I'm not sure which event you would want to use to put the sort back. Perhaps the window's internalFrameActivated?
...but it would go back like this:
sortedColumn, isAscending = # get this stuff from whereever it's stored
if sortedColumn is not None:
# Correct path to table as needed, and apply the sort
table = event.source.rootContainer.getComponent('Power Table').table
table.model.sortColumn(sortedColumn, True, isAscending)
Edit: added None type check to the apply sort script
Works great. Using table initialize event to apply sort. Thanks.