简体   繁体   中英

Adding a url column in celltable gwt

I'm workin on a web app using gwt, I have a celltable with textcolumns I want to add a column that will contain links, once the user clicks on a cell of this column he is forwaded to the link.

How can I do such a thing in gwt?

You would have to use a cell of appropriate type such as ClickableTextCell or ButtonCell as well as a FieldUpdater .

Basically you can add a FieldUpdater to your column as such:

column.setFieldUpdater(new FieldUpdater<YourObject, String>() {
        @Override
        public void update(int index, YourObject object, String value) {
            Window.open(value, "_blank", ""); //This will open link in a new tab or window
        }
    });

Where value in this case is the url. update() will be called when the column is clicked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM