Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT 2.1 CellTable Column Header click events

Tags:

java

gwt

Is there any way to add clickHandlers (or any type of handler) to the headers of the columns in a CellTable? I want to add some sorting functionality to my CellTable and I dont see any methods in the Column or Header classes that will allow this. I used this post to figure out how to use the CellTable.

like image 676
Carnell Avatar asked Jul 16 '10 05:07

Carnell


2 Answers

Workaround for click events:

Header<String> columnHeader = new Header<String>(new ClickableTextCell()) {
    @Override
    public String getValue() {
        return columnName;
    }
};

columnHeader.setUpdater(new ValueUpdater<String>() {
    @Override
    public void update(String value) {
        Window.alert("Header clicked!");
    }
});

table.addColumn(column, columnHeader);
like image 134
Italo Borssatto Avatar answered Nov 17 '22 19:11

Italo Borssatto


There is no out of the box way of supporting sort as yet on the CellTable. However there is a manual workaround involving a lot of code drudgery. Refer the classes SortableHeader and SortableColumn in the bike shed under expenses sample. You will find the usage in com.google.gwt.sample.expenses.gwt.client.ExpenseDetails. You can use this until something concrete comes out in the next release.

check out directory: http://google-web-toolkit.googlecode.com/svn/trunk/bikeshed

like image 3
Ashwin Prabhu Avatar answered Nov 17 '22 20:11

Ashwin Prabhu