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

自作多情 提交于 2019-12-25 08:03:49

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/40053932/how-to-customize-the-last-row-of-a-celltable-in-gwt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!