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

Prevent transfer of disabled items

4 Answers 129 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Albert Shenker asked on 19 Oct 2009, 04:12 PM
How do I prevent disabled items from being transfered if the user chooses to "transfer all" items from one listbox to another. By the way, shouldn't this be the default behavior? Since disabled items cannot be selected and transferred individually, why should they be transferred if a user chooses to transfer all?

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Oct 2009, 05:54 AM
Hi Albert,

I tried adding following client code in order to prevent transferring disabled items of RadListBox.

JavaScript:
 
<script type="text/javascript"
    function onClientTransferring(sender, e) { 
        //cancel the event 
        e.set_cancel(true); 
        //manually transfer the appropriate items 
        var items = e.get_items(); 
        for (var i = 0; i < items.length; i++) { 
            var item = items[i]; 
            if (item.get_enabled()) { 
                sender.transferItem(item, e.get_sourceListBox(), e.get_destinationListBox()); 
            } 
        } 
    } 
</script> 
[Attach onClientTransferring event to RadListBox.]

-Shinu.
0
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 20 Oct 2009, 06:36 AM
I tried your code and it worked, however the listbox transfer controls get confused. Because the source list still has items in it (albeit they are all disabled), then the transfer all back button doesn't get enabled. I'm not sure why. I would think the default behavior for the transfer all back button would be that it is always enabled when the destination list has items in it.
 
Also, and this is a bit off of this topic, is there a way to resort the items in the list after the transfer? It seems that setting the Sort="Ascending" doesn't maintain the sort and I'm not actually sure what that property does, except maybe sort the items on binding.. If you transfer items from the source to the destination, the items apear in the order they were transfered. The same thing occurs if you transfer items back to the source list. It would be nice if the items were resorted after transfer.
0
Genady Sergeev
Telerik team
answered on 20 Oct 2009, 07:58 AM
Hi Albert Shenker,

With the Q2 SP1, RadListBox no longer can transfer disabled items on the client site, we agreed that this should be the default behavior and we have fixed it. However, the problem still exists if you have the AutoPostBackOnTransfer property set to true. We will fix this for the Q3 release.

Preserving the order works on the client side, however there is still problem on the server side. It turned out that it is not a trivial task to preserve the order when transferring on the server, therefore we decided to provide a KB sample on how to do it. The sample should be available by the end of the week.

All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
answered on 20 Oct 2009, 03:40 PM
Thanks for the info. I don't typically do transfers on the server-side, so I believe I will be all set once Q3 comes out.
Tags
ListBox
Asked by
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Answers by
Shinu
Top achievements
Rank 2
Albert Shenker
Top achievements
Rank 1
Veteran
Iron
Genady Sergeev
Telerik team
Share this question
or