Pregunta

I'm using GXT 3.0 and have a Grid with multiple checkboxes each row. These checkboxes reflect certain properties of my row data and checkin/unchecking does not implies selecting/unselecting the particular row. How can I add a listener to each checkbox and perform some action upon clicking it?

¿Fue útil?

Solución

I override the handlesSelection() method to capture the check/uncheck event

CheckBoxCell checkCol = new CheckBoxCell() {
    @Override
    public boolean handlesSelection() {
        //TODO: 
        return true;
    }
};

Otros consejos

Add some CheckBoxSelectionModel for each checkbox

IdentityValueProvider<Stock> identity = new IdentityValueProvider<Stock>();
SpecialRowClickCheckBoxSelectionModel<Stock> sm = 
   new SpecialRowClickCheckBoxSelectionModel<Stock>(identity);

public class SpecialRowClickCheckBoxSelectionModel<M> 
     extends CheckBoxSelectionModel<M> {

  public SpecialRowClickCheckBoxSelectionModel(
         IdentityValueProvider<M> identity) {
    super(identity);
  }

  @Override
  protected void handleRowClick(RowClickEvent event) { 
       M model = listStore.get(event.getRowIndex());
       //TODO
  }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top