This is a migrated thread and some comments may be shown as answers.
Disable listbox (with transferlist) without hiding transferbuttons?
3 Answers 52 Views
This is a migrated thread and some comments may be shown as answers.
Datamex
Top achievements
Rank 2
Datamex asked on 09 Sep 2009, 12:08 PM
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)

<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">  
</telerik:RadListBox> 
<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">  
</telerik:RadListBox> 

http://bart.nimio.info/images/fora/listbox.JPG

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 09 Sep 2009, 12:55 PM
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.
0
Datamex
Top achievements
Rank 2
answered on 09 Sep 2009, 01:03 PM
But then the buttons are stil enabled... Can't the buttons just be disabled, without hiding them?
0
Genady Sergeev
Telerik team
answered on 11 Sep 2009, 01:01 PM
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.
Asked by
Datamex
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 1
Datamex
Top achievements
Rank 2
Genady Sergeev
Telerik team
Share this question
or