Packageorg.aswing.table.sorter
Classpublic class TableSorter
InheritanceTableSorter Inheritance AbstractTableModel
ImplementsTableModelListener

A class that make your JTable sortable. Usage:
 var sorter:TableSorter = new TableSorter(yourTableModel);
 sorter.setTableHeader(yourTable.getTableHeader());
 yourTable.setModel(sorter);
 



Public Properties
 PropertyDefined by
  ASCENDING : int = 1
[static]
TableSorter
  DESCENDING : int = -1
[static]
TableSorter
  LEXICAL_COMPARATOR : Function
[static]
TableSorter
  NOT_SORTED : int = 0
[static]
TableSorter
  NUMBER_COMAPRATOR : Function
[static]
TableSorter
Protected Properties
 PropertyDefined by
 InheritedcolumnClasses : Array
AbstractTableModel
 InheritedlistenerList : Array
List of listeners
AbstractTableModel
Public Methods
 MethodDefined by
  
TableSorter(tableModel:TableModel, tableHeader:JTableHeader = null)
TableSorter(tableModel:TableModel, tableHeader:JTableHeader)
TableSorter(tableModel:TableModel)
TableSorter()
TableSorter
 Inherited
Adds a listener to the list that's notified each time a change to the data model occurs.
AbstractTableModel
  
Cancels all sorting column to be NOT_SORTED.
TableSorter
 Inherited
findColumn(columnName:String):int
Returns a column given its name.
AbstractTableModel
  
getColumnClass(column:int):String
TableSorter
  
TableSorter
  
getColumnName(column:int):String
TableSorter
  
getComparator(column:int):Function
Returns the comparator function for given column.
TableSorter
  
getHeaderRendererIcon(column:int, size:int):Icon
TableSorter
  
TableSorter
  
TableSorter
  
getSortingStatus(column:int):int
TableSorter
  
TableSorter
  
TableSorter
 Inherited
Returns an array of all the table model listeners registered on this model.
AbstractTableModel
  
getValueAt(row:int, column:int):*
TableSorter
  
isCellEditable(row:int, column:int):Boolean
TableSorter
  
isColumnSortable(column:int):Boolean
Returns specified column sortable, default is true.
TableSorter
  
isSorting():Boolean
TableSorter
  
modelIndex(viewIndex:int):int
Calculates the model index from the sorted index.
TableSorter
 Inherited
Removes a listener from the list that's notified each time a change to the data model occurs.
AbstractTableModel
 Inherited
setColumnClass(columnIndex:int, className:String):void
Sets class name regardless of columnIndex.
AbstractTableModel
  
setColumnComparator(columnClass:String, comparator:Function):void
Sets a comparator the specified columnClass.
TableSorter
  
setColumnSortable(column:int, sortable:Boolean):void
Sets specified column sortable, default is true.
TableSorter
  
setSortingStatus(column:int, status:int):void
Sets specified column to be sort as specified direction.
TableSorter
  
setTableHeader(tableHeader:JTableHeader):void
Sets the table header
TableSorter
  
setTableModel(tableModel:TableModel):void
Sets the tableModel
TableSorter
  
setValueAt(aValue:*, row:int, column:int):void
TableSorter
  
TableSorter
 Inherited
toString():String
AbstractTableModel
Protected Methods
 MethodDefined by
 Inherited
fireTableCellUpdated(row:int, column:int):void
Notifies all listeners that the value of the cell at [row, column] has been updated.
AbstractTableModel
 Inherited
Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
AbstractTableModel
 Inherited
Notifies all listeners that all cell values in the table's rows may have changed.
AbstractTableModel
 Inherited
fireTableRowsDeleted(firstRow:int, lastRow:int):void
Notifies all listeners that rows in the range [firstRow, lastRow], inclusive, have been deleted.
AbstractTableModel
 Inherited
fireTableRowsInserted(firstRow:int, lastRow:int):void
Notifies all listeners that rows in the range [firstRow, lastRow], inclusive, have been inserted.
AbstractTableModel
 Inherited
fireTableRowsUpdated(firstRow:int, lastRow:int):void
Notifies all listeners that rows in the range [firstRow, lastRow], inclusive, have been updated.
AbstractTableModel
 Inherited
Notifies all listeners that the table's structure has changed.
AbstractTableModel
  
nextSortingStatus(curStatus:int, shiftKey:Boolean):int
TableSorter
Property detail
ASCENDINGproperty
public static var ASCENDING:int = 1
DESCENDINGproperty 
public static var DESCENDING:int = -1
LEXICAL_COMPARATORproperty 
public static var LEXICAL_COMPARATOR:Function
NOT_SORTEDproperty 
public static var NOT_SORTED:int = 0
NUMBER_COMAPRATORproperty 
public static var NUMBER_COMAPRATOR:Function
Constructor detail
TableSorter()constructor
public function TableSorter(tableModel:TableModel, tableHeader:JTableHeader = null)

TableSorter(tableModel:TableModel, tableHeader:JTableHeader)
TableSorter(tableModel:TableModel)
TableSorter()

Parameters
tableModel:TableModel
 
tableHeader:JTableHeader (default = null)
Method detail
cancelSorting()method
public function cancelSorting():void

Cancels all sorting column to be NOT_SORTED.

getColumnClass()method 
public override function getColumnClass(column:int):StringParameters
column:int

Returns
String
getColumnCount()method 
public override function getColumnCount():int

Returns
int
getColumnName()method 
public override function getColumnName(column:int):StringParameters
column:int

Returns
String
getComparator()method 
public function getComparator(column:int):Function

Returns the comparator function for given column.

Parameters
column:int

Returns
Function — the comparator function for given column.

See also

getHeaderRendererIcon()method 
public function getHeaderRendererIcon(column:int, size:int):IconParameters
column:int
 
size:int

Returns
Icon
getRowCount()method 
public override function getRowCount():int

Returns
int
getSortingColumns()method 
public function getSortingColumns():Array

Returns
Array
getSortingStatus()method 
public function getSortingStatus(column:int):intParameters
column:int

Returns
int
getTableHeader()method 
public function getTableHeader():JTableHeader

Returns
JTableHeader
getTableModel()method 
public function getTableModel():TableModel

Returns
TableModel
getValueAt()method 
public override function getValueAt(row:int, column:int):*Parameters
row:int
 
column:int

Returns
*
isCellEditable()method 
public override function isCellEditable(row:int, column:int):BooleanParameters
row:int
 
column:int

Returns
Boolean
isColumnSortable()method 
public function isColumnSortable(column:int):Boolean

Returns specified column sortable, default is true.

Parameters
column:int

Returns
Boolean — true if the column is sortable, false otherwish
isSorting()method 
public function isSorting():Boolean

Returns
Boolean
modelIndex()method 
public function modelIndex(viewIndex:int):int

Calculates the model index from the sorted index.

Parameters
viewIndex:int

Returns
int — the index in model from the sorter model index
nextSortingStatus()method 
protected function nextSortingStatus(curStatus:int, shiftKey:Boolean):intParameters
curStatus:int
 
shiftKey:Boolean

Returns
int
setColumnComparator()method 
public function setColumnComparator(columnClass:String, comparator:Function):void

Sets a comparator the specified columnClass. For example:

  setColumnComparator("Number", aNumberComparFunction);
  

Parameters
columnClass:String — the column class name
 
comparator:Function — the comparator function should be this spec: function(o1, o2):int, it should return -1 or 0 or 1.

See also

setColumnSortable()method 
public function setColumnSortable(column:int, sortable:Boolean):void

Sets specified column sortable, default is true.

Parameters
column:int — column
 
sortable:Boolean — true to set the column sortable, false to not
setSortingStatus()method 
public function setSortingStatus(column:int, status:int):void

Sets specified column to be sort as specified direction.

Parameters
column:int — the column to be sort
 
status:int — sort direction, should be one of these values:
  • DESCENDING : descending sort
  • NOT_SORTED : not sort
  • ASCENDING : ascending sort
setTableHeader()method 
public function setTableHeader(tableHeader:JTableHeader):void

Sets the table header

Parameters
tableHeader:JTableHeader — the table header
setTableModel()method 
public function setTableModel(tableModel:TableModel):void

Sets the tableModel

Parameters
tableModel:TableModel — the tableModel
setValueAt()method 
public override function setValueAt(aValue:*, row:int, column:int):voidParameters
aValue:*
 
row:int
 
column:int
tableChanged()method 
public function tableChanged(e:TableModelEvent):voidParameters
e:TableModelEvent