Tum
Tum

Reputation: 3652

How to insert Image into Column Header of CellTable (GWT)?

If we use Text for the header then it may take some space, so I want the Header have an icon(like Delete Icon) so I can save some space for the Header.

I tried

myCellTable.addColumn(deleteColumn,new SafeHtmlHeader(SafeHtmlUtils.fromSafeConstant
("<img width=\"30px\" height=\"30px\" src=\"image/icon/delete.png\">")));

It showed the image but the Image is very small about (10px - 10px) and it has a ugly border around the image.

SOmeone said using CUstom Header, but I couldn't override getHeaderStyleNames(). Ex:

class DeleteHeader extends Header{
    @Override
    public String getHeaderStyleNames(){
        return "css style";
    }
}

It said i have to override supertype something....!!

So how to fix it?

Upvotes: 0

Views: 771

Answers (1)

Andrei Volgin
Andrei Volgin

Reputation: 41089

Try this:

header.setHeaderStyleNames("deleteHeader");

Do not render image in this header. You can use a standard TextHeader, for example.

In CSS define this style with image as a background.

Upvotes: 1

Related Questions