don't allow transfer on certain item

5 posts, 1 answers
  1. appdev
    appdev avatar
    223 posts
    Member since:
    Sep 2008

    Posted 13 Jul 2009 Link to this post

    can i disable transfer function on certain item? in my case, if the item has value of 0 or "" or the item is enabled = false then do not allow transfering on that item. can i do that on client side? please help. thanks.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Jul 2009 Link to this post

    Hi Duy,

    Try the following clientside code for allowing transferring of items based on condition.

    ASPX:
     
    <telerik:RadListBox runat="server" ID="RadListBoxSource" Height="200px" Width="230px" 
        OnClientTransferring="OnClientTransferring" AllowTransfer="True" TransferToID="RadListBoxDestination"
        <Items> 
            <telerik:RadListBoxItem Text="Argentina" runat="server"   Value="0"/> 
            <telerik:RadListBoxItem Text="Australia" runat="server" Value="0" /> 
            <telerik:RadListBoxItem Text="Brazil" runat="server" Enabled="false" /> 
            <telerik:RadListBoxItem Text="Canada" runat="server" /> 
        </Items> 
    </telerik:RadListBox> 
    <telerik:RadListBox runat="server" ID="RadListBoxDestination" Height="200px" Width="200px"
    </telerik:RadListBox> 

    JavaScript:
     
    <script type="text/javascript"
    function OnClientTransferring(sender, args) 
        if(args.get_items().length >0) 
        { 
            for(var i=0; i< args.get_items().length; i++ ) 
            { 
                var text = args.get_items()[i].get_value(); 
                if(text == '0' || text == '' || !args.get_items()[i].get_isEnabled()) 
                { 
                    args.set_cancel(true); 
                    alert('The item cannot be transfered !'); 
                } 
            } 
        } 
    </script> 
    Note: I suggest you to set value as "0" rather than setting as null, because when I tried I am getting the value same as what I provide for text (when I set value as "").

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. appdev
    appdev avatar
    223 posts
    Member since:
    Sep 2008

    Posted 14 Jul 2009 Link to this post

    well, that works great. thank you for that.

    But if you hit transfer all button, nothing will get transfer. so how do you prevent that to happen and allow everything transfer over except for header?
  5. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 15 Jul 2009 Link to this post

    Hi Duy,

    Here is another idea - cancel the OnClientTransferring event and manually transfer the appropriate items using the transferItem method of RadListBox:

    function onClientTransferring(sender, e) {debugger 
        //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_text() != "0" && item.get_text() != "") { 
                sender.transferItem(item, e.get_sourceListBox(), e.get_destinationListBox()); 
            } 
        } 

    I hope this helps.

    Best wishes,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Arpit
    Arpit avatar
    1 posts
    Member since:
    Dec 2010

    Posted 23 Dec 2010 Link to this post

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