anttihavanko
26 Jul 2010, 9:37 AM
Hi
I'm trying to reorder EditorTreeGrid and update the model after dragdrop. I found out that calling store.getModels(), returns updated store but fetching models with getChild(i) doesn't. Is this a bug or should I "refresh" the store somehow? This only happens when model is dragged to some parent model (=new depth>0).
TreeStore<FoodModel>store = new TreeStore<FoodModel>();
EditorTreeGrid<FoodModel> grid = new EditorTreeGrid<FoodModel>(store, cm);
TreeGridDropTarget target = new TreeGridDropTarget(grid) {
@Override
protected void onDragDrop(DNDEvent e) {
super.onDragDrop(e);
final ArrayList<TreeStoreModel> arr = (ArrayList<TreeStoreModel>)e.getData();
final TreeStoreModel mT = arr.get(0);
final FoodModel m = (FoodModel)mT.getModel();
System.out.println("Dragged model: "+m.getName());
//get grid
final EditorTreeGrid<FoodModel> gridNew = (EditorTreeGrid<FoodModel>)e.getDropTarget().getComponent();
final TreeStore<FoodModel> store = (TreeStore<FoodModel>)gridNew.getTreeStore();
//print with getModels()
for(FoodModel mm : store.getModels()) {
System.out.println("With getModels(): "+mm.getName());
}
//print with getChild(i)
System.out.println("");
for(int i=0; i<store.getChildCount(); i++)
{
FoodModel mm = store.getChild(i);
System.out.println("With getChild(): "+mm.getName());
for(int j=0; j<mm.getChildCount(); j++) {
System.out.println(" - child: "+((FoodModel)mm.getChild(j)).getName());
}
}
}
}
And when "Model1" is dragged from different grid to "Parent2" that prints:
Dragged model: Model1
With getModels(): Parent1
With getModels(): Model2
With getModels(): Parent2
With getModels(): Model3
With getModels(): Model1
With getChild(): Parent1
- child: Model2
With getChild(): Parent2
- child: Model3
It seems that child models are not updated correctly? I hope somebody understands what I'm trying to say :D
I'm trying to reorder EditorTreeGrid and update the model after dragdrop. I found out that calling store.getModels(), returns updated store but fetching models with getChild(i) doesn't. Is this a bug or should I "refresh" the store somehow? This only happens when model is dragged to some parent model (=new depth>0).
TreeStore<FoodModel>store = new TreeStore<FoodModel>();
EditorTreeGrid<FoodModel> grid = new EditorTreeGrid<FoodModel>(store, cm);
TreeGridDropTarget target = new TreeGridDropTarget(grid) {
@Override
protected void onDragDrop(DNDEvent e) {
super.onDragDrop(e);
final ArrayList<TreeStoreModel> arr = (ArrayList<TreeStoreModel>)e.getData();
final TreeStoreModel mT = arr.get(0);
final FoodModel m = (FoodModel)mT.getModel();
System.out.println("Dragged model: "+m.getName());
//get grid
final EditorTreeGrid<FoodModel> gridNew = (EditorTreeGrid<FoodModel>)e.getDropTarget().getComponent();
final TreeStore<FoodModel> store = (TreeStore<FoodModel>)gridNew.getTreeStore();
//print with getModels()
for(FoodModel mm : store.getModels()) {
System.out.println("With getModels(): "+mm.getName());
}
//print with getChild(i)
System.out.println("");
for(int i=0; i<store.getChildCount(); i++)
{
FoodModel mm = store.getChild(i);
System.out.println("With getChild(): "+mm.getName());
for(int j=0; j<mm.getChildCount(); j++) {
System.out.println(" - child: "+((FoodModel)mm.getChild(j)).getName());
}
}
}
}
And when "Model1" is dragged from different grid to "Parent2" that prints:
Dragged model: Model1
With getModels(): Parent1
With getModels(): Model2
With getModels(): Parent2
With getModels(): Model3
With getModels(): Model1
With getChild(): Parent1
- child: Model2
With getChild(): Parent2
- child: Model3
It seems that child models are not updated correctly? I hope somebody understands what I'm trying to say :D