Sorting a CellTable server-side

后端 未结 4 1144
说谎
说谎 2021-01-24 14:30

I\'m currently using a Gwt CellTable, bound to my GAE/Objectify backend via RPC calls.

All right now! :-)

Then I want to sort columns, so I read http://code.goog

4条回答
  •  广开言路
    2021-01-24 15:02

    You can keep a list of column names ordered as they are in the table:

    List columnNames = new ArrayList();
    
    table.addColumn(surnameColumn, "surname");
    columnNames.add("surname");
    
    // add the other columns
    

    Then when you need to get the sort column name:

    String sortColumnName;
    ColumnSortList sortList = table.getColumnSortList();
    if (sortList != null && sortList.size() != 0){
         Column  sortColumn = (Column ) 
                                               sortList.get(0).getColumn();
         Integer columnIndex = table.getColumnIndex(sortColumn);
         sortColumnName = columnNames.get(columnIndex);
    }
    
    // do your rpc call
    

    *where MyEntity is your data object displayed in the cell table.

提交回复
热议问题