1. #1
    Ext User
    Join Date
    Nov 2009
    Posts
    81
    Vote Rating
    0
    Nico33 is on a distinguished road

      0  

    Default 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);
        }
    }

  2. #2
    Ext User
    Join Date
    Nov 2009
    Posts
    81
    Vote Rating
    0
    Nico33 is on a distinguished road

      0  

    Default


    Hi all,

    this is the complete test app that reproduces the problem :

    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);
        }
    }
    Click on the button, that opens the windows.
    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)

  3. #3
    Ext User
    Join Date
    Nov 2009
    Posts
    81
    Vote Rating
    0
    Nico33 is on a distinguished road

      0  

    Default


    Maybe the listview doesn't work on a window ...

  4. #4
    Ext User
    Join Date
    Nov 2009
    Posts
    81
    Vote Rating
    0
    Nico33 is on a distinguished road

      0  

    Default


    no idea ?

  5. #5
    Ext User
    Join Date
    Nov 2009
    Posts
    81
    Vote Rating
    0
    Nico33 is on a distinguished road

      0  

    Default


    I'll give up this idea, and will try something without a window ...

  6. #6
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    Remove the call to setBounds. This is unneeded in the place you have it and is making the problem

  7. #7
    Ext User
    Join Date
    Nov 2009
    Posts
    81
    Vote Rating
    0
    Nico33 is on a distinguished road

      0  

    Default


    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 ?

  8. #8
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    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.

Thread Participants: 1