Prevent transfer of disabled items

5 posts, 0 answers
  1. Albert Shenker
    Albert Shenker avatar
    588 posts
    Member since:
    Mar 2004

    Posted 19 Oct 2009 Link to this post

    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?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Oct 2009 Link to this post

    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.
  3. Albert Shenker
    Albert Shenker avatar
    588 posts
    Member since:
    Mar 2004

    Posted 20 Oct 2009 Link to this post

    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.
  4. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 20 Oct 2009 Link to this post

    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.
  5. Albert Shenker
    Albert Shenker avatar
    588 posts
    Member since:
    Mar 2004

    Posted 20 Oct 2009 Link to this post

    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.
Back to Top