Java Table Component Column Sorting

I was wondering if there was a property of the Table component that displayed which column was sorted: i.e. If column A,B,C was sorted, if any, and if it were ascending or descending. The purpose of this is that we have a table with 3 columns (timestamp, error type, and machine) and some users may want to have the report sorted by different columns to view the data.


Well, I thought there was a way to do this, but it turns out there isn’t, at least not in the current version. But, when the next version comes out, you’ll be able to do this:

The following code will work in version 3.2.4 or later.

[code]# This code will print out the sort states for each table column

table = event.source.parent.getComponent(“Table”).viewport.view
columnModel = table.columnModel
states = {0: “Sorted Ascending”, 1: “Sorted Descending”, 2: “Not sorted”}

for x in range(columnModel.columnCount):
column = columnModel.getColumn(x)
header = column.headerValue
sortMode = header.state
print “Column %s is %s” % (header.display, states[sortMode])[/code]

OK sounds good. Looks easy enough once the update comes out. Thanks!