9

GWTでセルテーブルを使用しています。そのセルテーブルにこれらの列を追加しています。

    TextColumn<Document> idColumn = new TextColumn<Document>() {
        @Override
        public String getValue(Document object) {
            return Long.toString(object.getId());
        }
    };
    TextColumn<Document> refColumn = new TextColumn<Document>() {
        @Override
        public String getValue(Document object) {
            return object.getReferenceNumber();
        }
    };
    /*
     * DateCell dateCell = new DateCell(); Column<Contact, Date> dateColumn
     * = new Column<Contact, Date>(dateCell) {
     * 
     * @Override public Date getValue(Contact object) { return
     * object.birthday; } };
     */
    TextColumn<Document> nameColumn = new TextColumn<Document>() {
        @Override
        public String getValue(Document object) {
            return object.getDocumentName();
        }
    };
            table = new CellTable<T>();
    table.addColumn(idColumn, "Id");
    table.addColumn(refColumn, "Reference Number");
    table.addColumn(nameColumn, "Name");
}

今私はいくつかのクエリを持っています:id列を非表示にする方法は?行をクリックすると、選択した行からどのように取得できますか?私を助けてください。前もって感謝します。

4

1 に答える 1

14

Well you could try to use fixed layout for the CellTable and set the width of the specific column you want to hide to 0px. I did use another approach.

In my case I have a cellTable which should display a checkbox column as soon as I press a button (which puts the celltable in edit mode). I do this by creating a CheckBoxColumn and inserting and removing it when I press on the button. It looks seomething like that:

@Override
public void insertCheckBoxColumn(Column<Object,Boolean> column) {
    if (cellTable.getColumnIndex(column) == -1) {
        cellTable.addColumn(column,"");
        cellTable.setColumnWidth(column,50, Unit.PX);
    }
}

@Override
public void removeCheckBoxColumn(Column<Object, Boolean> column) {
    int index = cellTable.getColumnIndex(column);
    if (index != -1)
         cellTable.removeColumn(index);
}

However note that you might run into this issue on google chrome.

于 2011-08-22T13:41:33.007 に答える