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

Selectionmode = "Single" Not Working

1 Answer 172 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 26 Sep 2011, 06:34 PM
Hello,

I have a RadListBox that is will only allow multiple selection. I have Selectionmode="Single" set but that does not work. I have also tried some Javascript with no luck. Obviously this is a bug but what can I do hear to get the selection mode to single.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DataMigration.ascx.cs"
    Inherits="PDS.DataMigration1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<style type="text/css">
    .style8
    {
        color: #FFFFFF;
    }
</style>
<telerik:RadScriptBlock ID="ScriptBlock" runat="server">
<script type="text/javascript">
  
    function reMigrate()
    {
        var button = $find("<%= rb_Migrate.ClientID %>");
        button.click();
    }
</script>
</telerik:RadScriptBlock>
<div style="text-align: center; width: 100%">
    <div style="text-align: left">
        <div style="text-align: center; width: 700px; margin-top: 40px">
            <asp:Panel ID="Panel2" runat="server" Width="650px" Height="450px" BackColor="#62768A">
                <span class="style8">
                    <label>
                        Select Dealership</label></span>
                <br />
                <telerik:RadComboBox runat="server" ID="rcb_Dealerships" Width="280px" AutoPostBack="true"
                    EnableEmbeddedSkins="false" OnDataBinding="rcb_Dealerships_DataBinding" OnSelectedIndexChanged="rcb_Dealerships_SelectedIndexChanged">
                </telerik:RadComboBox>
                <br />
                <br />
                <span class="style8">
                    <label style="text-align: left">
                        Select Accounts</label></span>
                <br />
                <telerik:RadListBox ID="rlb_Accounts" runat="server" Width="600px" Height="300px" CheckBoxes="true" EnableEmbeddedSkins="false"
                BackColor="#E1EAF2" BorderColor="#E1EAF2" style="text-align: left" AutoPostBack="true" SelectionMode="Single" >
                </telerik:RadListBox>
                <br />
                <br />
                <telerik:RadButton ID="rb_Migrate" runat="server" Width="150px" Text="Migrate Accounts"
                    Skin="WebBlue" BackColor="#33393E" ForeColor="Black" OnClick="rb_Migrate_Click">
                </telerik:RadButton>
                <telerik:RadWindowManager ID="RadWindowManager1" runat="server" 
                    EnableEmbeddedSkins="false" EnableViewState="false" >
                    <%--<Windows>
                    <telerik:RadWindow runat="server" ID="ProductWin">
                    </telerik:RadWindow>
                    </Windows>--%>
                </telerik:RadWindowManager>
                <br />
                <cc1:RoundedCornersExtender ID="RoundedCornersExtender2" runat="server" TargetControlID="Panel2"
                    Radius="9">
                </cc1:RoundedCornersExtender>
            </asp:Panel>
        </div>
    </div>
</div>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="WebBlue">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="Panel2">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="Panel2" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
        <telerik:AjaxSetting AjaxControlID="GridPanel">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="GridPanel" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>

1 Answer, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 26 Sep 2011, 07:25 PM

Fixed. If your selectionmode is not working when set to selectionmode = "Single", call this javascript function on the "OnClientItemChecking" event:

function singleSelection(sender, args)
    {
        var item = args.get_item();
        var items = sender.get_items();
        var checked = item.get_checked();
        if (checked == false)
        {
            items.forEach(function (itm) { itm.set_checked(false); });
        }
    }
Tags
ListBox
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Share this question
or