how to add column of ClickableTextCells to cellTable

后端 未结 3 515
挽巷
挽巷 2021-01-12 23:17

hi all i need a simple example show me how to add column of ClickableTextCells to cellTable

thanks.

3条回答
  •  时光说笑
    2021-01-12 23:37

    this is the solution if you need to add clickableTextCell to cellTable

    // ClickableTextCell
    
    ClickableTextCell anchorcolumn = new ClickableTextCell();
    table.addColumn(addColumn(anchorcolumn, new GetValue() {
            public String getValue(Contact contact) {
                return "Click " + contact.anchor;
            }
        }, new FieldUpdater() {
            public void update(int index, Contact object, String value) {
                Window.alert("You clicked " + object.name);
            }
        }), "Anchor");
    
    
    
    private  Column addColumn(Cell cell,final GetValue getter,
    FieldUpdater fieldUpdater) {
            Column column = new Column(cell) {
    
            @Override
            public C getValue(Contact object) {
                return getter.getValue(object);
            }
        };
        column.setFieldUpdater(fieldUpdater);
    
        return column;
    }
    
    private static interface GetValue {
        C getValue(Contact contact);
    }
    
    
    // A simple data type that represents a contact.
        private static class Contact {
            private final String address;
            private final String name;
            private final String anchor;
    
            public Contact(String name, String address, String anchor) {
                this.name = name;
                this.address = address;
                this.anchor = anchor;
            }
        }
    

提交回复
热议问题