Hello experts,

I have followed this example 
<http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwDataGrid> and 
have added a column with a cell, DatePickerCell for a DataGrid.
Using gwt 2.7.0.

Before the DatePickerCell's value is changed I check for the row selection, 
if row is a selected one I would make the change otherwise restore the old 
date.
Two cases:
1. Current state: checkBox is unchecked, hence the row is an unselected row:

- on change of the DatePickerCell, I throw a message to select the row 
first and restores the old date

- after this when I click on checkBox, it gets checked but the row does not 
get selected (on this first click)

- next when I click the checkBox again (for the 2nd time now), it does not 
get unchecked but the row gets selected

 
2. Current state: checkBox is checked, hence the row is a selected row:

- on change of the DatePickerCell, the change is accepted

- after this when I click on the checkBox, it gets unchecked but the row 
does not get unselected (on this first click)

- next when I click the checkBox again (for the 2nd time now), it does not 
get checked but the row gets unselected


For other columns with EditTextCell cell the checkBox row selection is 
working fine.
How to fix this?

The selection model (a multiple selection model) code and checkBox column 
code is followed as is given in the link (example 
<http://samples.gwtproject.org/samples/Showcase/Showcase.html#!CwDataGrid>)
Pasting below code which I have used to add a column with DataPickerCell:
DateTimeFormat dateFormat = DateTimeFormat.getFormat( 
PredefinedFormat.DATE_MEDIUM );
final Column<InterfaceTableRow, Date> fromIntOwnConcDateColumn = new 
Column<InterfaceTableRow, Date>(new DatePickerCell(dateFormat)) {
@Override
public Date getValue(InterfaceTableRow object) {
return object.getFromInterfaceOwnerConcurrenceDate();
}
};
// set sortable
fromIntOwnConcDateColumn.setSortable(true);
// set own comparator
sortHandler.setComparator(fromIntOwnConcDateColumn, new 
Comparator<InterfaceTableRow>() {
@Override
public int compare(InterfaceTableRow o1, InterfaceTableRow o2) {
return 
o1.getFromInterfaceOwnerConcurrenceDate().compareTo(o2.getFromInterfaceOwnerConcurrenceDate());
}
});
// add to dataGrid
dataGrid.addColumn( fromIntOwnConcDateColumn, 
InterfaceTableRow.COL_NAME_FROM_INT_OWNER_CONC_DATE );
// field updater
fromIntOwnConcDateColumn.setFieldUpdater(new 
FieldUpdater<InterfaceTableRow, Date>() {
@Override
public void update(int index, InterfaceTableRow object, Date value) {

// called when the user changes the value
// check if the object is selected i.e. the check box is checked
if( selectionModel.isSelected( object ) ) {

object.setFromInterfaceOwnerConcurrenceDate( value );

// add to map keeping details about the changed rows
// old itr value would anyway get replaced with this new one
mapChangedIntTableRows_uniqueIdToIntTableRow.put( object.getUniqueId(), 
object );
InterfaceTableDataModel.get().refreshDisplays();
}
else {
Window.alert( "Please select the row first to edit this field!!" );
((DatePickerCell) fromIntOwnConcDateColumn.getCell() ).clearViewData( 
InterfaceTableDataModel.KEY_PROVIDER.getKey( object ) );
//dataGrid.redraw();
dataGrid.redrawRow( index );
//selectionModel.setSelected( object, true );
//selectionModel.setSelected( object, false );
}
}
});

Thanks,
Ved

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

Reply via email to