Disable listbox (with transferlist) without hiding transferbuttons?

4 posts, 0 answers
  1. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 09 Sep 2009 Link to this post

    Would it be possible to disable the listboxes without hiding the buttons that make it possible to swap items between the lists? (in other words, some sort of "ReadOnly"-mode, without changing the look of the controls)

    1 <telerik:RadListBox ID="DualList" runat="server" AllowTransfer="true" AllowTransferOnDoubleClick="false" 
    DataSourceID="EmployeesDataSource" DataTextField="Name" DataValueField="EmployeeID" TransferToID="TransferToList" 
    Width="230px" Height="200px" Culture="Dutch (Netherlands)" EnableDragAndDrop="false" SelectionMode="Multiple" 
    OnDataBound="DualList_DataBound" Enabled="false">  
    2 </telerik:RadListBox> 
    3 <telerik:RadListBox ID="TransferToList" runat="server" DataSourceID="PreferredEngineersDataSource" DataTextField="Name" 
    DataValueField="EmployeeID" Width="230px" Height="200px" AllowTransfer="false" AllowTransferOnDoubleClick="false" 
    Culture="Dutch (Netherlands)" EnableDragAndDrop="false" SelectionMode="Multiple" OnDataBound="TransferToList_DataBound" 
    Enabled="false">  
    4 </telerik:RadListBox> 

    http://bart.nimio.info/images/fora/listbox.JPG
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Sep 2009 Link to this post

    Hello,

    Try the approach by attaching ' OnClientTransferring ' event to RadListBox and prevent the item transferring using set_cancel(true) method in the event handler.

    ASPX:
     
    <telerik:RadListBox ID="DualList" runat="server" AllowTransfer="true" AllowTransferOnDoubleClick="false" 
        DataTextField="Name" DataValueField="EmployeeID" TransferToID="TransferToList" OnClientTransferring="ClientTransferring" 
        Width="230px" Height="200px" Culture="Dutch (Netherlands)" EnableDragAndDrop="false" 
        SelectionMode="Multiple" >      
    </telerik:RadListBox> 
    <telerik:RadListBox ID="TransferToList" runat="server" Width="230px" Height="200px" 
        AllowTransfer="false" AllowTransferOnDoubleClick="false" Culture="Dutch (Netherlands)" 
        EnableDragAndDrop="false" SelectionMode="Multiple" > 
    </telerik:RadListBox> 

    JavaScript:
     
    <script type="text/javascript"
    function ClientTransferring(sender, args) 
    {     
        args.set_cancel(true); 
        alert('The item cannot be transfered !');     
    </script> 

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 09 Sep 2009 Link to this post

    But then the buttons are stil enabled... Can't the buttons just be disabled, without hiding them?
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 11 Sep 2009 Link to this post

    Hi Datamex,

    You can use the following code to disable the buttons:

     function pageLoad() { 
                var listBox = $find("rlb"); 
                disableButtons(listBox); 
                $telerik.$(".rlbItem", listBox.get_element()) 
                    .live("click"function(e) { 
                        disableButtons(listBox); 
                    }); 
               
            } 
            function disableButtons(listBox) { 
                var $ = $telerik.$; 
                listBox._updateButton("rlbTransferFrom"false); 
                listBox._updateButton("rlbTransferTo"false); 
                listBox._updateButton("rlbTransferAllFrom"false); 
                listBox._updateButton("rlbTransferAllTo"false); 
            } 

    You can call the disableButtons functon whenever you want to have all the buttons disabled.

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