Drag & Drop between list boxes - enforce One-Way

8 posts, 0 answers
  1. Andrew
    Andrew avatar
    34 posts
    Member since:
    Dec 2010

    Posted 06 Sep 2011 Link to this post

    There is a bewildering number of options that can be placed on list boxes when it comes to drag-and-drop.

    It there a combination of options that I can set that enforces the following:

      - Items can be copied from lstAvailableFiles to lstAssignedFiles, either by dragging or by button presses
      - Items can not be dragged in any way from lstAssignedFiles to lstAvailableFiles
      - lstAvailableFiles
     cannot be reoordered
      - Once an item is in lstAssignedFiles, items can be reoordered or removed

    I have tried various options, but I cannot seem to make lstAvailableFiles a drag source without making it a drop target as well.

    I've enclosed an image of the controls, and here is the current code.

    <tr>
       <td>
          <Telerik:RadListBox
              ID="lstAssignedFiles"
              runat="server"
              Width="100%"
              Rows="20"
              SelectionMode="Multiple"
              Height="250px" 
              EnableDragAndDrop="true"
              AllowTransferDuplicates="true"
              AllowReorder="True"
              AllowTransfer="False"
              AllowDelete="True"
              ButtonSettings-Position="Left"
              ButtonSettings-ShowTransfer="False"
              ButtonSettings-ShowTransferAll="False" />
     
       </td>
       <td>
          <Telerik:RadListBox
              ID="lstAvailableFiles"
              runat="server"
              Width="100%"
              Rows="20"
              SelectionMode="Multiple"
              AllowTransfer="true"
              AllowTransferDuplicates="true"
              EnableDragAndDrop="true"
              TransferMode="Copy"
              TransferToID="lstAssignedFiles"
              ButtonSettings-Position="Left"
              Height="250px"  />
       </td>
    </tr>



  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 12 Sep 2011 Link to this post

    Hello Andrew,

    Please review the attached project. It implements your requirements. In case you need more information about the RadListBox properties, consult with the following help article(you can also check the whole section functionality).

    Greetings,
    Peter Filipov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ricardo Pinto
    Ricardo Pinto avatar
    36 posts
    Member since:
    Sep 2008

    Posted 25 Sep 2011 Link to this post

    Hello Peter!

    I have almost the same scenario as Andrew: two listboxes ItemTypes and FormItems and I want to configure it to enforce one-way "movement":
    • Items can be copied from ItemTypes to FormItems allowing duplicates, by drag-and-drop
    • Items can not be reordered in ItemTypes
    • Items can be reordered in FormItems, by drag-and-drop or listbox buttons
    • Items can be deleted in FormItems, by listbox button
    • If item is dragged from FormItem to the outside (ItemTypes or html controls on the page), it should also be deleted from FormItems source

    The example you've attached works well but it's not using AllowTransferDuplicate="true", which I really need to have.
    If I set this property to true, it will allow to transfer/drag back to ItemTypes, duplicating the items in this listbox, which shouldn't happen as it contains a fixed list of available item types.

    To avoid this I temporarily disabled drag-and-drop in FormItems, reordering with the buttons only.
    But this way the usability of the intended functionality gets significantly reduced :(

    Is there a way of configuring my intended scenario?

    Thanks in advance for your support!

    Ricardo Pinto.

    Ps: Andrew, did you ever got a solution for your requirements?
  5. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 28 Sep 2011 Link to this post

    Hello Ricardo,

    To accomplish your scenario please use the following client side events: OnClientDropping and OnClientTransferring.

    With dropping event handler you can check on which element the item is going to be dropped and remove it from it's RadListBox control.
    With transferring event handler you can check if in the destination listbox exists an item with the same text and decide whether to transfer/duplicate it.

    Regards,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  6. Ricardo Pinto
    Ricardo Pinto avatar
    36 posts
    Member since:
    Sep 2008

    Posted 28 Sep 2011 Link to this post

    Hello Peter!

    Thanks for your reply.

    As my development continued, I had to stop using automatic operations and ended up implementing some server side events: rlbItemTypes_Transferred, rlbFormItems_ReOrdered and rlbFormItems_Deleted.

    With this different strategy, I no longer have the issue of inserting duplicates in the ItemTypes listbox: if I drag from FormItems to ItemTypes it will call the rlbFormItems_Deleted event and do the necessary database delete.

    Meanwhile, when I started using Itemtemplates, I stumbled upon a different issue, as described in this post.
    Can you please take a look?

    Thanks again!
    Best regards,

    Ricardo.
  7. Andrew
    Andrew avatar
    34 posts
    Member since:
    Dec 2010

    Posted 28 Sep 2011 Link to this post

    Hi Ricardo, 

    No, I never got this to work and had to move on.

    My solution to the customers is "There's no reason to move them back again, so just don't do it".  That's good enough for my project. :-)

    Thanks for continuing the discussion, I'd be interested to see if this is solvable.

  8. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 03 Oct 2011 Link to this post

    Hi Ricardo,

    I have consulted with Genady Sergeev and he will give you an answer in the other thread.

    Greetings,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  9. Ricardo Pinto
    Ricardo Pinto avatar
    36 posts
    Member since:
    Sep 2008

    Posted 03 Oct 2011 Link to this post

    Hello Peter.

    I will wait for Genady's reply then :)
    Thank you both for the help!

    Best regards,

    Ricardo.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017