Domanda

ho creato un ButtonCell e un Colonna per esso:

ButtonCell previewButton = new ButtonCell();
Column<Auction,String> preview = new Column<Auction,String>(previewButton) {
  public String getValue(Auction object) {
    return "Preview";
  }
};

Come faccio ora aggiungere un gestore di clic (ad esempio, clickHandler ) per questo ButtonCell ?

È stato utile?

Soluzione

The Cell Sampler example includes use of clickable ButtonCells. Clicks on ButtonCells are handled by setting the FieldUpdater for the Column:

preview.setFieldUpdater(new FieldUpdater<Auction, String>() {
  @Override
  public void update(int index, Auction object, String value) {
    // The user clicked on the button for the passed auction.
  }
});

Altri suggerimenti

 //Prevent mouse events  for table cell
 CellPreviewEvent.Handler<Auction > manager = DefaultSelectionEventManager.createBlacklistManager(4);//column number
 cellTable.setSelectionModel(selectionModel, manager);

 new Column<Auction , String>(new ButtonCell()){

    @Override
    public String getValue(Auction object) {
        return "Preview";
    }

    @Override
    public void onBrowserEvent(Cell.Context context, Element elem, Auction object, NativeEvent event) {
        event.preventDefault();

       //TODO implement event handling 
    }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top