-
10 Feb 2010 7:30 AM #1
ListView disappears when Dnd
ListView disappears when Dnd
Hi all,
I'm trying to use drag and drop on a ListView to allow reordering.
Here's my code snippet, but when I'm dragging an element, the listview disappears.
Am I missing something ?
Thanks in advance for any help
Code:public class ListViewDnd extends LayoutContainer { @Override protected void onRender(Element parent, int index) { super.onRender(parent, index); Window w = new Window(); w.setPlain(true); w.setSize(580, 550); w.setLayout(new FitLayout()); ListStore<Stock> store = new ListStore<Stock>(); store.add(TestData.getCompanies()); ListView<Stock> lv = new ListView<Stock>(); lv.setStore(store); lv.setSimpleTemplate("{name}"); lv.setBounds(10, 10, 160,60); lv.setSize(400, 300); lv.setBorders(true); addDragDropSupport(lv); w.add(lv); w.show(); } public static void addDragDropSupport(ListView<? extends ModelData> listView) { new ListViewDragSource(listView); ListViewDropTarget target = new ListViewDropTarget(listView); target.setAllowSelfAsSource(true); target.setFeedback(Feedback.INSERT); } }
-
4 Mar 2010 11:01 AM #2
Hi all,
this is the complete test app that reproduces the problem :
Click on the button, that opens the windows.Code:public class TestApp implements EntryPoint { private ListView<Stock> lv; private ListViewDropTarget target; public void onModuleLoad() { Viewport viewport = new Viewport(); viewport.setLayout(new AnchorLayout()); LayoutContainer container = new LayoutContainer(); Button button = new Button("Open"); button.setSize(50, 50); button.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { Window w = new Window(); w.setPlain(true); w.setSize(580, 550); w.setLayout(new FitLayout()); ListStore<Stock> store = new ListStore<Stock>(); store.add(TestData.getCompanies()); lv = new ListView<Stock>(); lv.setStore(store); lv.setSimpleTemplate("{name}"); lv.setBounds(10, 10, 160,60); lv.setSize(400, 300); lv.setBorders(true); new ListViewDragSource(lv); target = new ListViewDropTarget(lv); target.setAllowSelfAsSource(true); target.setFeedback(Feedback.INSERT); w.add(lv); w.show(); } }); container.add(button); viewport.add(container , new AnchorData("100% 100%", new Margins(10))); RootPanel.get().add(viewport); } }
Try to do anything on the listview (for example moving the scrollbar or beginning a DnD), the listview disappears.
How can I correct that ?
Thanks in advance for your help.
(note with gxt 2.1.1 it appears only on DnD, not while moving the scrollbar)
-
8 Mar 2010 3:49 AM #3
Maybe the listview doesn't work on a window ...

-
9 Mar 2010 9:30 AM #4
-
11 Mar 2010 4:41 AM #5
I'll give up this idea, and will try something without a window ...
-
11 Mar 2010 5:31 AM #6
Remove the call to setBounds. This is unneeded in the place you have it and is making the problem
-
11 Mar 2010 1:04 PM #7
Thanks, this is working as usual.
To avoid in the future to annoy you, how did you achieve to know what was wrong in my code ?
I tryed to debug, but can't see what's wrong.
Why did setbounds run this issue and how to prevent it ?
-
11 Mar 2010 1:08 PM #8
setBounds was setting a top and left value. The dragging set position to relative and so it was jumping away.
I simple started the testcode and looked at it with firebug before and after dragging. That was how i found it.


Reply With Quote