1

我创建了带有复选框列表的 radcombobox。用户可以选择多个复选框,并且当他检查页面上的某些项目标签时必须更新(this.label.text += someValue)。我在该 radcombobox 上添加了带有异步触发器的 Ajax:UpdatePanel 但问题是当用户检查项目下拉列表时自行关闭它:( 如何防止关闭下拉列表?这是我尝试过的:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<telerik:RadComboBox runat="server" ID="rcb" Width="200px" HighlightTemplatedItems="true" 
    AllowCustomText="true" Text="Select Item" MaxHeight="250px" EnableTextSelection="false" AutoPostBack="true"
    OnClientSelectedIndexChanging="OnClientSelectedIndexChanging()">
    <Items>
        <telerik:RadComboBoxItem Value="0" Text="Select..." />
        <telerik:RadComboBoxItem Value="1" Text="Small" />
        <telerik:RadComboBoxItem Value="2" Text="Medium" />
        <telerik:RadComboBoxItem Value="3" Text="Large" />
    </Items>
    <ItemTemplate>        
            <asp:CheckBox onclick="stopPropagation(event);" ID="chk_Category" runat="server" Text="test" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" />       
    </ItemTemplate>    
</telerik:RadComboBox>

<dnn:label ID="lbl" runat="server" Text="nothing" />

</ContentTemplate>
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="rcb"/>    
</Triggers>
</asp:UpdatePanel>

<script type="text/javascript" language="javascript">
        // <![CDATA[
    function stopPropagation(e) {        
        e.cancelBubble = true;
        if (e.stopPropagation) {
            e.stopPropagation();
        }
    }
    function OnClientSelectedIndexChanging(item) {       
        return false;
    }

                // ]]>
</script>
4

1 回答 1

1

Typically, the drop down closes when you click on the item; we use a checkbox in the combo box template, and only experienced the closing when clicking on the item itself (which selects the item, and that becomes confusing).

The issue here is that each checkbox posts back to the server, so that is the most likely cause. Do you have to send the checkbox response back to the server after clicking it? An alternative approach is to read the checkbox controls from each item in bulk, or every time an item is checked, store the values of the checked items in a hidden control.

Alternatively, as an FYI, for the Q2 release of 2011, upcoming is this feature: Multiple select with checkboxes mode. So checkboxes will be a default feature of the combo box. If you have support, you can upgrade shortly.

HTH.

于 2011-06-09T12:07:55.760 回答