on ‎2004 Sep 29 3:07 PM
Has anybody successfully tried sorting columns of a tableview component by clicking on its header? I need to sort a column containing dates in mm/dd/yyyy format. Please share your hints or code. BR, Maulin
Request clarification before answering.
Hi,
I'm using java classes (not jsp's). In the funtion where you create the TableView component, do the following after creating the table:
for( int i=1; i<this.columnsCount; i++ ) {
com.sapportals.htmlb.table.TableColumn column = tableView.getColumn(i);
// sorry for the strange notation
if( 'column is sotable' && !('data is empty') ) {
column.setOnHeaderSort("onTableHeaderSortEventId");
column.setSortState( getColumnSortState() );
}
}
private TableSortState getSortState() {
// this method should return for the sorted column
// either TableSortState.ASCENDING or
// TableSortState.DESCENDING
// for all others: TableSortState.NONE
}
If someone now clicks on the header to sort the column you get the following declared event:
//...
if( "onTableHeaderSortEventId".equals(pageCtx.getCurrentEvent().getAction()) ) {
if( pageCtx.getCurrentEvent() instanceof TableHeaderSortEvent ) {
TableHeaderSortEvent event = (TableHeaderSortEvent) pageCtx.getCurrentEvent();
int column = event.getColumn();
// now sort the data according to the column
}
}
Hope this helps.
Greetings,
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.