How to add clickhandler on ImageCell in GWT CellTable?

前端 未结 8 1303
再見小時候
再見小時候 2021-02-06 04:01

I have tried this but didn\'t work

Column imageColumn = new Column(new ImageCell()) {
       @Override
             


        
8条回答
  •  时光说笑
    2021-02-06 04:30

    You can try this rather than using ButtonCell or ImageCell. This will work for sure. As I have implemented for my requirement. Let me know how does it goes..

     ClickableTextCell imageCell = new ClickableTextCell() {
            @Override
            public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
                if (data != null) {
                    String imagePath = "icon.png";
                    sb.append(imagePath);
                }
            }
        };
    
    Column imageColumn = new Column(imageCell) {
           @Override
           public String getValue(ContactInfo object) {
               return "";
              }
            };
            imageColumn.setFieldUpdater(new FieldUpdater() {
    
            @Override
            public void update(int index, ContactInfo object, String value) {
            Window.alert("You clicked " + object.firstName);
            }
    
        });
    cellTable.addColumn(imageColumn, SafeHtmlUtils.fromSafeConstant("
    "));

提交回复
热议问题