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

Handling item transferring on double click

7 Answers 449 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Oded
Top achievements
Rank 1
Oded asked on 18 Feb 2010, 11:37 AM
Hello,

I want to allow moving of items from one listbox to another by double clicking an item.
I have a javascript function that checks if the move is allowed and I use it with the OnClientTransferring event.
I want to use this function also with the OnClientItemDoubleClicking event but I don't have the same event arguments supplied.

does anyone knows why isn't the OnClientTransferring invoked when transferring an item using double click?

Thanks,
Oded

7 Answers, 1 is accepted

Sort by
0
Joshua Holt
Top achievements
Rank 2
answered on 19 Feb 2010, 05:12 PM
HI Oded,
You can accomplish this task by setting the 2 list boxes making the to list boxes related to each other by either setting the TransferToID in code, or in the ListBox control's smart tag, select the releated list box.  Then handle the double click event of both list boxes
Javascript:
    function doubleClick(s, e) {            
            var item = e.get_item(); 
            s.transferToDestination(item); 
        } 

Page:
<telerik:RadListBox ID="RadListBox1" runat="server"  
        onclientitemdoubleclicked="doubleClick" TransferToID="RadListBox2"
        <Items> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem1" /> 
            <telerik:RadListBoxItem runat="server" Text="RadListBoxItem2" /> 
        </Items> 
    </telerik:RadListBox> 
    <telerik:RadListBox ID="RadListBox2" runat="server" TransferToID="RadListBox1" onclientitemdoubleclicked="doubleClick"
    </telerik:RadListBox> 
Double clicking an item in ListBox1 will now send it to ListBox2,  double clicking in ListBox2 will send it to ListBox1.

You could run your function to check if the move is allowed in the double click handler.

You can see more ways to handle item transfer between list boxes on the RadListBox Client API Help Page.

I hope this helps you!
-Josh






0
Oded
Top achievements
Rank 1
answered on 21 Feb 2010, 09:05 AM
Thank you Josh,

Maybe I was not so clear. I that the OnClientTransferring event will be fired when I transfer the item with double click. Or have similar event arguments in the OnClientItemDoubleClicking event.

Thanks,

Oded
0
Genady Sergeev
Telerik team
answered on 22 Feb 2010, 08:50 AM
Hi Oded,

The double click transfer fires the OnClientTransferring/Transferred events. You need to set the AllowTransferOnDouble click property of the source RadListBox to true and then add event handlers for the previous mentioned events. I have attached sample project that demonstrates this.

Kind regards,
Genady Sergeev
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
Oded
Top achievements
Rank 1
answered on 23 Feb 2010, 12:12 PM
Hello Genady,

I don't know why but the OnClientTransferring is not firing when I double click on an item on the AvailableListBox but it does fire when I double click on an item on the SelectedListBox:

 <telerik:RadListBox ID="AvailableListBox" runat="server" TransferToID="SelectedListBox" 
      AllowTransfer="true" OnClientTransferring="clientTransferring" AllowTransferOnDoubleClick="true" 
      TransferMode="Move" Width="275" Height="400">  
      <ButtonSettings AreaWidth="30" ShowTransfer="true" ShowTransferAll="false" Position="Right" 
        VerticalAlign="Middle" /> 
    </telerik:RadListBox> 
<telerik:RadListBox ID="SelectedListBox" TransferMode="Move" runat="server" 
      Width="245" Height="400" TransferToID="AvailableListBox" AllowTransferOnDoubleClick="true">  
    </telerik:RadListBox> 

This markup is inside a user control. I have two user controls on the page and altogether four listboxes.

Any Ideas?

Thanks,
Oded
Software
Top achievements
Rank 1
commented on 03 Feb 2023, 02:58 PM

Thanks Oded!! solved my problem and seems like a "bug" in the control to not allow the event to fire if the other RadListBox is married to the firing RadListBox
0
Genady Sergeev
Telerik team
answered on 24 Feb 2010, 04:56 PM
Hello Oded,

I am not able to reproduce the issue, on my side the events is fired for both the source and the destination RadListBox. Which version of the controls are you using?

Greetings,
Genady Sergeev
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
Oded
Top achievements
Rank 1
answered on 25 Feb 2010, 07:58 AM
Hi,

I Upgraded to the latest version and it didn't solve the problem.

But I found what was the problem.

Here you can see that on the SelectedListBox the TransferToID is set to the AvailableListBox. When I removed this attribute from the second RadListBox the event started to fire.
 <telerik:RadListBox ID="AvailableListBox" runat="server" TransferToID="SelectedListBox"   
      AllowTransfer="true" OnClientTransferring="clientTransferring" AllowTransferOnDoubleClick="true"   
      TransferMode="Move" Width="275" Height="400">    
      <ButtonSettings AreaWidth="30" ShowTransfer="true" ShowTransferAll="false" Position="Right"   
        VerticalAlign="Middle" />   
    </telerik:RadListBox>   
<telerik:RadListBox ID="SelectedListBox" TransferMode="Move" runat="server"   
      Width="245" Height="400" TransferToID="AvailableListBox" AllowTransferOnDoubleClick="true">    
    </telerik:RadListBox>   
 

So the working markup is:
 <telerik:RadListBox ID="AvailableListBox" runat="server" TransferToID="SelectedListBox"   
      AllowTransfer="true" OnClientTransferring="clientTransferring" AllowTransferOnDoubleClick="true"   
      TransferMode="Move" Width="275" Height="400">    
      <ButtonSettings AreaWidth="30" ShowTransfer="true" ShowTransferAll="false" Position="Right"   
        VerticalAlign="Middle" />   
    </telerik:RadListBox>   
<telerik:RadListBox ID="SelectedListBox" TransferMode="Move" runat="server"   
      Width="245" Height="400">    
    </telerik:RadListBox>   
 

I guess this is a bug.

Thanks,
Oded
0
Genady Sergeev
Telerik team
answered on 26 Feb 2010, 01:31 PM
Hello Oded,

Thank you for pointing this out. Actually there is no need to set the TransferToID  property of the destination RadListBox. It is sufficient to set in on the source one and the transfer will work as expected.

Regards,
Genady Sergeev
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.
Tags
ListBox
Asked by
Oded
Top achievements
Rank 1
Answers by
Joshua Holt
Top achievements
Rank 2
Oded
Top achievements
Rank 1
Genady Sergeev
Telerik team
Share this question
or