This is a migrated thread and some comments may be shown as answers.

Drag & Drop between list boxes - enforce One-Way

7 Answers 142 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Iron
Iron
Andrew asked on 07 Sep 2011, 01:48 AM
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>



7 Answers, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 12 Sep 2011, 11:42 AM
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
0
Ricardo Pinto
Top achievements
Rank 1
answered on 26 Sep 2011, 01:19 AM
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?
0
Peter Filipov
Telerik team
answered on 28 Sep 2011, 02:10 PM
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
0
Ricardo Pinto
Top achievements
Rank 1
answered on 28 Sep 2011, 03:35 PM
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.
0
Andrew
Top achievements
Rank 1
Iron
Iron
answered on 29 Sep 2011, 12:25 AM
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.

0
Peter Filipov
Telerik team
answered on 03 Oct 2011, 09:25 AM
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
0
Ricardo Pinto
Top achievements
Rank 1
answered on 03 Oct 2011, 09:31 AM
Hello Peter.

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

Best regards,

Ricardo.
Tags
ListBox
Asked by
Andrew
Top achievements
Rank 1
Iron
Iron
Answers by
Peter Filipov
Telerik team
Ricardo Pinto
Top achievements
Rank 1
Andrew
Top achievements
Rank 1
Iron
Iron
Share this question
or