9

I am using Cell Table in GWT.In that cell table I am adding these columns.

    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");
}

Now I have some queries: How to hide the id column? On click of row how can i get the from selected row? Please help me out. Thanks in advance.

Sanjay Jain
  • 3,518
  • 8
  • 59
  • 93

1 Answers1

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.

Ümit
  • 17,379
  • 7
  • 55
  • 74
  • How do u manage the Column Ordering issue when insert, remove muptiple columns, pls read this question http://stackoverflow.com/questions/21630708/how-to-fix-the-column-ordering-issue-when-insert-and-remove-columns-in-gwt – Kiti Feb 07 '14 at 15:08