2016-07-26 9 views

Antwort

1

Verwenden Sie die RowSelectionModel. Das folgende Snippet wird aus dem _5052_RowSelectionExample der NatTable-Beispiele extrahiert.

// use a RowSelectionModel that will perform row selections and is able 
// to identify a row via unique ID 
selectionLayer.setSelectionModel(new RowSelectionModel<Person>(
selectionLayer, bodyDataProvider, new IRowIdAccessor<Person>() { 

    @Override 
    public Serializable getRowId(Person rowObject) { 
     return rowObject.getId(); 
    } 

})); 

// register the DefaultRowSelectionLayerConfiguration that contains the 
// default styling and functionality bindings (search, tick update) 
// and different configurations for a move command handler that always 
// moves by a row and row only selection bindings 
selectionLayer.addConfiguration(new DefaultRowSelectionLayerConfiguration()); 

Der beste Weg, um NatTable zu lernen, ist ein Blick auf die NatTable Anwendungsbeispiele zu haben. Es ist als WebStart-Anwendung über die NatTable homepage verfügbar. Oder Sie können die Beispiel-Jar-Datei herunterladen und von command line ausführen, wenn WebStart nicht funktioniert.

Das Beispiel zu betrachten unter Tutorial Beispiele gelegen -> Ebenen -> Auswahl -> RowSelectionExample