How to add clickhandler on ImageCell in GWT CellTable?

前端 未结 8 1436
再見小時候
再見小時候 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:56

    I got all the above and added them in my app. Thanks to all. stackoverflow rocks!

        ButtonCell bc = new ButtonCell() {
            @Override
            public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
                if (data != null) {
                    ImageResource icon = Connector.imageResources.minus();
                    Image image = new Image(icon);
                    //fix the mouse pointer
                    image.getElement().getStyle().setCursor(Cursor.POINTER);
                    //Do something with the DATA
                    image.setTitle("Delete " + data.asString());
                    SafeHtml html = SafeHtmlUtils.fromTrustedString(image.toString());
                    sb.append(html);
                }
            }
        };
        Column imageColumn = new Column(bc) {
            @Override
            public String getValue(InstanceProperty object) {
                //return the DATA
                return object.getKey();
            }
        };
        imageColumn.setFieldUpdater(new FieldUpdater() {
            @Override
            public void update(int index, InstanceProperty property,
                    String value) {
                //you can also use the DATA to do something
                InstancePropertiesTable.this.dataProvider.getList().remove(index);
            }
        });
        addColumn(imageColumn, "");
    

提交回复
热议问题