PDA

View Full Version : [CLOSED] [1.2.4] DND on Grid with GroupingView cannot change group



jschwarz0
8 May 2009, 1:03 PM
GXT 1.2.4 (and 2.0m1)
all modes/browsers/os's

Hi,

This is either a bug, feature request or question...

1) open the "Grids->Grouping" example and make it support dnd (see code below, just 4 lines added).
2) run
3) drag "Intel" from Computer to Finance
4) note nothing happens as the underlying model does not get changed

How can I make the drop stick?
I tried to make a ChangeListener for that BaseModel; but how do I get the destination group of the drop?

Thanks,
Jim

---

protected void onRender(Element parent, int index)
{
super.onRender(parent, index);

setLayout(new FlowLayout(10));

GroupingStore<Stock> store = new GroupingStore<Stock>();
store.add(TestData.getCompanies());
store.groupBy("industry");

ColumnConfig company = new ColumnConfig("name", "Company", 60);
ColumnConfig price = new ColumnConfig("open", "Price", 20);
ColumnConfig change = new ColumnConfig("change", "Change", 20);
ColumnConfig industry = new ColumnConfig("industry", "Industry", 20);
ColumnConfig last = new ColumnConfig("date", "Last Updated", 20);
last.setDateTimeFormat(DateTimeFormat.getFormat("MM/dd/y"));

List<ColumnConfig> config = new ArrayList<ColumnConfig>();
config.add(company);
config.add(price);
config.add(change);
config.add(industry);
config.add(last);

final ColumnModel cm = new ColumnModel(config);

GroupingView view = new GroupingView();
view.setForceFit(true);
view.setGroupRenderer(new GridGroupRenderer()
{
public String render(GroupColumnData data)
{
String f = cm.getColumnById(data.field).getHeader();
String l = data.models.size() == 1 ? "Item" : "Items";
return f + ": " + data.group + " (" + data.models.size() + " " + l + ")";
}
});

Grid<Stock> grid = new Grid<Stock>(store, cm);
grid.setView(view);
grid.setBorders(true);

GridDragSource gds = new GridDragSource(grid);
GridDropTarget gdt = new GridDropTarget(grid);
gdt.setAllowSelfAsSource(true);
gdt.setFeedback(Feedback.INSERT);

ContentPanel panel = new ContentPanel();
panel.setHeading("Grouping Example");
panel.setIconStyle("icon-table");
panel.setCollapsible(true);
panel.setFrame(true);
panel.setSize(700, 450);
panel.setLayout(new FitLayout());
panel.add(grid);

add(panel);
}

sven
8 May 2009, 1:26 PM
This is not a bug. You need to apply the logic to change the groupingfield.