1

I have sortable columns A and B . When user click on column A to sort , my result datas should sort via column A type and column B will show relative datas.When user was clicked on column B to sort , my result datas should sort via column B type and column A will show relative datas. I followed column sorting as GWT Column Sort example by using GWT DataGrid with AsyncDataProvider. This example show single column sorting and I would like to use one or more column sorting but I don't know how to determine
which column was fired column sort event ?

At my RPC method ,

    AsyncHandler handler = new AsyncHandler(myGridTable);
    myGridTable.addColumnSortHandler(handler);
    myGridTable.getColumnSortList().push(A_column);
    myGridTable.getColumnSortList().push(B_column);

    AsyncDataProvider<AdminModel> provider = new AsyncDataProvider<AdminModel>() {
        protected void onRangeChanged(final HasData<AdminModel> display) {
            final int start = display.getVisibleRange().getStart();
            int length = display.getVisibleRange().getLength();

            AsyncCallback<String> callback = new AsyncCallback<String> {
                public void onFailure(final Throwable caught) {
                    Window.alert(caught.getMessage());
                }
                public void onSuccess(final String result) {
                    ........
                    updateRowData(start, adminList);
                }
            };
            final ColumnSortList sortList = myGridTable.getColumnSortList();
            // Here to determine which column sort

            // send request to server
        }
    };

    provider.addDataDisplay(view.getDataGridResults());
Cataclysm
  • 7,592
  • 21
  • 74
  • 123

1 Answers1

1

See here for details.

Basically view.getDataGridResults().getColumnSortList().get(0).getColumn() will return the column the user clicked on.

If you want to get also the other columns (for example for multiple sorting) you have to check also the indices > 0 (i.e. get(1).getColumn())

Once you have the column you can check the direction by calling view.getDataGridResults().getColumnSortList().get(0).getColumn().isAscending()

Community
  • 1
  • 1
Ümit
  • 17,379
  • 7
  • 55
  • 74
  • Now I can get **Column** sir but how to know is it column **A** or **B** ? Pls help me sir . Thanks for your answer. – Cataclysm Jun 05 '14 at 07:53
  • Fine , I got it bro... `Column sortColumn = (Column) sortList.get(0).getColumn(); myGridTable.getColumnIndex(sortColumn);` – Cataclysm Jun 05 '14 at 08:06
  • column index can determine which type of column to be sorted. Thanks for your help bro. – Cataclysm Jun 05 '14 at 08:08