0
votes

I have a celltable in GWT and want to implement sorting functionality on it , from database(Criteria) for that i just want to know how to get the value of the column which has been clicked for sorting

here is my code

            ctJobs.addColumnSortHandler(new ColumnSortEvent.Handler() {
            public void onColumnSort(ColumnSortEvent event) { 
            event.getColumn();
            event.getColumn().getValue("what do we need to write here ???");

from event.getColumn() , i am getting column in the form of object

com.google.gwt.cell.client.ClickableTextCell@188a12e

I want to know the the column's name / value for that i am trying event.getcolumn().getvalue("??"); but what is the parameter for that, or is there any other way of getting column's name which has been clicked.

Thanks

2

2 Answers

4
votes

Are you using a ListDataProvider or an AsyncDataProvider for your cell table?

In case of an AsyncDataProvider the sorting must be done on the server side, so there is no need to add a ColumnSortHandler.

Please see the GWT docs.

To get the name of the column clicked for sorting see this question.

1
votes

When creating the table columns, set the dataStoreName of the column.

column.setDataStoreName("columnX");

Next, when in the AsyncDataProvider get the sort history of the clicked headers like the following

final AsyncDataProvider<SQLRow> dataProvider = new AsyncDataProvider<SQLRow>(){
    @Override
    protected void onRangeChanged(HasData<SQLRow> display) {
        for (int i=0;i<sortList.size();i++) {
            sortList.get(i).getColumn().getDataStoreName();
        }
    }
}