3

am using GWT 2.4, Hibernate and MysQL I created a cell table , when i click on a cell i want to display the data/value in that particular cell

Thanks in advance

GLN
  • 161
  • 3
  • 14

2 Answers2

0

Use DataProvider and SingleSelectionModel for you cellTable:

private final ListDataProvider<SomeClass> dataProvider = new ListDataProvider<SomeClass>();

private final SingleSelectionModel<SomeClass> selectionModel = new SingleSelectionModel<SomeClass>();
//then
table.setSelectionModel(selectionModel);    
dataProvider.addDataDisplay(table);  

Heres how u can get the selected objects info:

        showDataValueOfCellBtn.addClickHandler(new ClickHandler() {     
        @Override
        public void onClick(ClickEvent event) {
            SomeClass selected = selectionModel.getSelectedObject();
            Window.alert (selected.getValue());
        }
    });  
Omar Wagih
  • 8,504
  • 7
  • 59
  • 75
WelcomeTo
  • 19,843
  • 53
  • 170
  • 286
0
@override
public Widget onInitialize(){

    CellTable grid = new CellTable<Bean>();
    grid.setWidth("100%",true);

    setColumns(grid);
}

private void setColumns(CellTable grid){

     Column<Bean, String> firstNameColumn = new Column<Bean, String>(
        new EditTextCell()) {
      @Override
      public String getValue(Bean object) {
        return object.getFirstName();
      }
    };
    firstNameColumn.setSortable(true);
    grid.addColumn(firstNameColumn, "First Name");

    Column<Bean, String> imageColumn = new Column<Bean, String>(
        new ClikableTextCell()) {
      @Override
      public String getValue(Bean object) {
        return "clickhere";
      }
    };
    imageColumn.setSortable(true);
    grid.addColumn(imageColumn, "Add Information");
    firstNameColumn.setFieldUpdater(new FieldUpdater<Bean, String>() {
      public void update(int index, Bean object, String value) {
        Window.alert("You clicked " + object.getFullName());
      }
    });
    cellTable.setColumnWidth(firstNameColumn, 20, Unit.PCT);
}
user229044
  • 232,980
  • 40
  • 330
  • 338
PVR
  • 2,534
  • 18
  • 38