简体   繁体   中英

How to customize the last row of a CellTable in GWT?

Assume each row has the format:

Data   | <Delete Button>

Now I am trying to add an empty row at the end. And I would like to not showing the <Delete Button> at the last row. I added the empty data through data provider. Is there a way to achieve this?

There is a method you can override when you create a column:

Column<MyObject, Number> myColumn = new Column<MyObject, Number>(new NumberCell()) {

    @Override
    public String getCellStyleNames(Context context, MyObject myObject) {
        return context.getIndex() == displayItems.size() - 1 ? "hide" : null;
    }  
};

context.getIndex() gives you a row number. You can define a CSS style in your CSS file like "hide" with a rule "opacity: 0" or "display: none", and return this style only for the last row.

My example is NumberCell, but it applies to all cells.

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