- 追加された行はこの色です。
- 削除された行はこの色です。
#sortabletable(sort=String|Number){{
|LEFT:80|LEFT:150|c
|果物|価格|h
パターン3追加色テスト用1
#sortabletable(||String|Number|Number|Number|Number|Number|Number|Number|String){{{
|CENTER:|LEFT:160|CENTER:30|CENTER:30|BGCENTER:30|CENTER:30|BGCENTER:30|CENTER:30|BGCENTER:30|CENTER:30|BGCENTER:30|LEFT:|LEFT:|c
|果物|価格|h
|林檎|25|
|オレンジ|5|
|梨|20|
|マンゴー|500|
}}
<script type="text/javascript">
<!--
new OrderByColumn("tableID",["type_of_column", ... ]);
//-->
</script>
#table_edit(ほげふが)
[ソートしたい列の番号1][追加指定記号1] : [ソートしたい列の番号2][追加指定記号2]
[果物][林檎] : [価格][25]
#table_edit(表ページの名前 [, ソート文字列])
#sortabletable(Number|String|String,1){{{
#table_edit(ほげふが)
#table_edit(ほげふが, 2)
#table_edit(ほげふが, 2n)
#table_edit(ほげふが, 2nr)
|CENTER:年度||CENTER: 男 |CENTER: 女 ||CENTER:TOTAL|
|幅255pix|幅64pix|
|||||||
|CENTER:2001||RIGHT:20|RIGHT:30||RIGHT:50|
|CENTER:2002||RIGHT:30|RIGHT:40||RIGHT:70|
|||||||
|CENTER:TOTAL||RIGHT:50|RIGHT:70||RIGHT:120|
|LEFT:255|RIGHT:64|c
|幅255pix|幅64pix|
|>|>|CENTER:40|c
|1|>|2|>|3|
|4|5|7|
|~|8|~|
|9|10|11|
|>|12|>|
/*sortabletable.js*/
.sort-arrow {
width: 17px;
height: 17px;
background-position: center center;
background-repeat: no-repeat;
margin: 0 2px;
background-image: url("../image/blank.png");
}
.sort-arrow.descending {
background-image: url("../image/downsimple.png");
}
.sort-arrow.ascending {
background-image: url("../image/upsimple.png");
}
/*filterabletable.js*/
.filter-box {
width: 100%;
height: 1.5em;
margin: 0;
}
}}
}}}
class SortableTableModel extends DefaultTableModel {
public SortableTableModel(String[] str, int row) {
super(str, row);
}
public void sortByColumn(int column, boolean isAscent) {
Collections.sort(getDataVector(), new ColumnComparator(column, isAscent));
fireTableDataChanged();
}
}
class ColumnComparator implements Comparator {
final protected int index;
final protected boolean ascending;
public ColumnComparator(int index, boolean ascending) {
this.index = index;
this.ascending = ascending;
}
public int compare(Object one, Object two) {
if (one instanceof Vector && two instanceof Vector) {
Object oOne = ((Vector) one).elementAt(index);
Object oTwo = ((Vector) two).elementAt(index);
if (oOne == null && oTwo == null) {
return 0;
} else if (oOne == null) {
return ascending ? -1 : 1;
} else if (oTwo == null) {
return ascending ? 1 : -1;
} else if (oOne instanceof Comparable && oTwo instanceof Comparable) {
Comparable cOne = (Comparable) oOne;
Comparable cTwo = (Comparable) oTwo;
return ascending ? cOne.compareTo(cTwo) : cTwo.compareTo(cOne);
}
}
return 1;
}
public int compare(Number o1, Number o2) {
double n1 = o1.doubleValue();
double n2 = o2.doubleValue();
if (n1 < n2) {
return -1;
} else if (n1 > n2) {
return 1;
} else {
return 0;
}
}
}