jQWidgets Forums

jQuery UI Widgets Forums Lists ListBox listbox drag and drop – Get all moved items

This topic contains 4 replies, has 3 voices, and was last updated by  Gopre400 10 years, 11 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • jbeasley
    Member

    Hi,

    I’m using 2 listboxes with drag-and-drop enabled.  Is there a simple or recommended way of retrieving all of the items which have been moved from one list to the other?  The ‘GetItems’ method retrieves all of the items in a list, whether they were there when the list was originally rendered from the source, or subsequently dragged there from the other list.

    Thanks.


    Dimitar
    Participant

    Hello jbeasley,

    The solution is to put the moved item in an array with all the moved items on the dragEnd event.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    jbeasley
    Member

    Many thanks Dimitar,
    I thought of that also. However, I was wondering about the DragEnd event….doesn’t this event only get triggered if the item is dropped onto another item in the target list? When the event is raised it carries two arguments – the dropped item, and the item in the target list onto which the dragged item was dropped. I found when experimenting with this that the event was triggered fine as long as there was an item in the target list, onto which my dragged item was dropped. If the target list is empty, or if i drag an item onto the bottom of the target list (not onto an item already in the list), then the DragEnd event is not raised.


    Gopre400
    Participant

    Hi Dimitar, is there another way to retrieve all the items from target list than storing in separate array? If an item is removed from target list then the array needs to be updated…


    Gopre400
    Participant

    Nevermind, I just used getitems and it worked fine…

    $(‘#btnOK’).on(‘click’, function () {
    var items = $(“#listBoxB”).jqxListBox(‘getItems’);
    var log = “”;
    for (var i = 0; i < items.length; i++) {
    log += items[i].value;
    if (i < items.length – 1) log += ‘, ‘;
    }
    alert(log);
    });

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.