I tried this, and it works, with two issues:

1. you need to remove the existing instance of the column.  Unlike regular 
DOM elements (and therefore Widgets), which can only be in one place at a 
time, the cells generate a rendered string, which will be a new snippet of 
HTML, which will be result in new DOM element.  And, apparently, nothing 
the table logic is policing the number of times a given column can appear, 
so the column will exist in two locations: the original location pushed one 
to the right if the insert position was before it, and the new location.

2. With a DatePickerCell, the first time I changed the date via the 
"popup", nothing happened in the table, but the column updater did get 
invoked, and refreshing the document, or just paging forward and back 
again, showed me that the update had taken, and I saw the new data.  
Subsequent edits to cells in that column did reflect immediately in the 
table.

Code snippet:

private CellTable<Customer> ct = new CellTable<Customer>(pageRows);

// later, as the last column in the table:
Column<Customer, Date> expiresColumn = 
    new Column<Customer, Date>(
        new DatePickerCell(DateTimeFormat.getMediumDateFormat())) {
    @Override
    public Date getValue(Customer cust) {
        return cust.getExpiration();
    }
};
expiresColumn.setFieldUpdater(new FieldUpdater<Customer, Date>() {
    @Override
    public void update(int index, Customer cust, Date value) {
        cust.setExpiration(value);
        custUpdater.updateCustomer(cust);
    }
});
TextHeader expiresHeader = new TextHeader("Expiration");
ct.addColumn(expiresColumn, expiresHeader);

// after finishing table setup, and adding everything to the Root Panel
int colIndex = ct.getColumnIndex(expiresColumn);
Column<Customer, ?> col = ct.getColumn(colIndex);
ct.removeColumn(expiresColumn);
ct.insertColumn(0, col, expiresHeader);


On Saturday, June 30, 2012 5:23:08 AM UTC-4, Thomas Broyer wrote:
>
>
>
> On Saturday, June 30, 2012 11:17:03 AM UTC+2, tong123123 wrote:
>>
>> If  the celltable has something like 
>> addColumn(Column<T,?> col, int insertIndex) 
>>
>
> insertColumn(int beforeIndex, Column<T,?> 
> col)<http://google-web-toolkit.googlecode.com/svn/javadoc/latest/com/google/gwt/user/cellview/client/AbstractCellTable.html#insertColumn(int,+com.google.gwt.user.cellview.client.Column)>
>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/bv9-T7-sE6AJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to