PDA

View Full Version : [GXT 2.0 trunk] Bug in dnd between EditorGrid and Grid



xalvaro
26 May 2009, 6:05 AM
I have a problem when doing drag'n drop between a grid and a gridEditor :

Grid Column Model :

ColumnConfig column = new ColumnConfig();
column.setId("name");
column.setHeader(messages.label_AttributeName());
column.setWidth(260);
column.setResizable(false);
column.setMenuDisabled(true);
column.setSortable(false);
configs.add(column);

ColumnConfig column2 = new ColumnConfig();
column2.setId("selected");
configs.add(column2);
column2.setRenderer(new GridCellRenderer()
{

@Override
public Object render(final ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore store, Grid grid)
{
CheckBox check = new CheckBox();
check.setValue((Boolean) model.get("selected"));
check.setFireChangeEventOnSetValue(true);
return check;
}

});
ColumnModel cm = new ColumnModel(configs);

Grid :


GridDragSource src = new GridDragSource(grid);
src.getDraggable().setStartDragDistance(5);

EditorGrid Column Model :

List<ColumnConfig> configs = new ArrayList<ColumnConfig>();

ColumnConfig column = new ColumnConfig();
column.setId("name");
column.setHeader("Attribute Name");
column.setWidth(100);
configs.add(column);

ColumnConfig columnOperators = new ColumnConfig();
columnOperators.setId("operator");
columnOperators.setHeader("Operator");
columnOperators.setWidth(50);

final SimpleComboBox<Operators> combo = new SimpleComboBox<Operators>();
combo.setTriggerAction(TriggerAction.ALL);
for (int i = 0; i < Operators.values().length; i++)
{
combo.add(Operators.values()[i]);
}
;
CellEditor editor = new CellEditor(combo)
{

@Override
public Object preProcessValue(Object value)
{
if (value == null)
{
return value;
}
return combo.findModel((Operators)value);
}

@Override
public Object postProcessValue(Object value)
{
if (value == null)
{
return value;
}
return ((ModelData) value).get("value");
}
};
columnOperators.setEditor(new CellEditor(combo));
configs.add(columnOperators);

column = new ColumnConfig();
column.setId("value");
column.setHeader("Value");
column.setWidth(100);
TextField<String> text = new TextField<String>();
column.setEditor(new CellEditor(text));
configs.add(column);

ColumnModel cm = new ColumnModel(configs);
EditorGrid :

GridDropTarget drop = new GridDropTarget(editorGrid);
drop.setOperation(Operation.COPY);
drop.setFeedback(Feedback.INSERT);

My baseModel

public WizardAttributeModel(BAttribute bAttribute)
{
this.set("name", bAttribute.getName());
this.set("selected", true);
this.set("bAttribute", bAttribute);
this.set("operator", Operators.EQUAL);
this.set("value", " ");
}

issue : when dnd, the checkbox is also copied in the editor grid, in the column "operator" which is normally a combobox, and the checkbox in the grid disappear.
It seems that the Cellrenderer(here a checkbox) is moved from the grid to the editor grid

Any idea?