0

我正在尝试在 RadComboBoxItem 中创建复选框组。当单击组 1 时,我希望选择所有组 1,并且组 2 的所有组都被选中,同时选中所有选项。(但是我希望能够设置所有检查的样式,所以我将其设置为一个额外的选项)。So this all works fine, my only issue is that when one option is selected it closes the dropd down... How can i keep it from doing so?

组合框:

   EnableAutomaticLoadOnDemand="True" DropDownWidth="380px">
    <Items>
        <telerik:RadComboBoxItem runat="server" BackColor="Gray" ForeColor="White" 
                     Owner="txtAlertType" Text="Check All" Value="0" />
        <telerik:RadComboBoxItem runat="server" Text="Stop Payment Submitted" 
            Value="13" />
        <telerik:RadComboBoxItem runat="server" BackColor="DarkGray" IsSeparator="True" 
            Owner="txtAlertType" Text="Custom Alerts" Value="0" />
        <telerik:RadComboBoxItem runat="server" Text="Login" Value="12" />
        <telerik:RadComboBoxItem runat="server" Text="Matures in X Days" Value="1" />
        <telerik:RadComboBoxItem runat="server" BackColor="DarkGray" IsSeparator="True" 
            Owner="txtAlertType" Text="Cash Management" Value="0" />
        <telerik:RadComboBoxItem runat="server" Text="Payment Due in X Days" 
            Value="2" />
        <telerik:RadComboBoxItem runat="server" Text="Batch Approved" Value="21" />
        <telerik:RadComboBoxItem runat="server" Text="Balance &gt; $" Value="3" />
        <telerik:RadComboBoxItem runat="server" Text="Batch Prossed" Value="22" />
        <telerik:RadComboBoxItem runat="server" Text="Balance &lt; $" Value="4" />
        <telerik:RadComboBoxItem runat="server" Text="Positive Pay Exception" 
            Value="25" />
        <telerik:RadComboBoxItem runat="server" Text="Pending ACH" Value="5" />
        <telerik:RadComboBoxItem runat="server" Text="Bank Received Wire &gt; $" 
            Value="24" />
        <telerik:RadComboBoxItem runat="server" Text="Balance Alert" Value="6" />
        <telerik:RadComboBoxItem runat="server" Text="Wire Approved" Value="23" />
        <telerik:RadComboBoxItem runat="server" Text="Check # Cleared" Value="7" />
        <telerik:RadComboBoxItem runat="server" Text="Wire Submitted &gt; $" 
            Value="26" />
        <telerik:RadComboBoxItem runat="server" Text="Deposit &gt; $" Value="8" />
        <telerik:RadComboBoxItem runat="server" Text="Wire Transfer Rejected by User" 
            Value="27" />
        <telerik:RadComboBoxItem runat="server" Text="Debit &gt; $" Value="9" />
        <telerik:RadComboBoxItem runat="server" Text="Wire Transfer Rejected by Bank" 
            Value="28" />
        <telerik:RadComboBoxItem runat="server" Text="NSF Items Today" Value="10" />
        <telerik:RadComboBoxItem runat="server" Text="Wire Transfer Deleted by User" 
            Value="29" />
        <telerik:RadComboBoxItem runat="server" 
            Text="Online Transaction Processed" Value="11" />
        <telerik:RadComboBoxItem runat="server" Text="Wire Transfer Deleted by Bank" 
            Value="30" />
    </Items>
</telerik:RadComboBox>

后面的代码:

Protected Sub OnItemChecked(ByVal sender As Object, ByVal e As RadComboBoxItemEventArgs)

    Select Case e.Item.Text
        Case "Check All"
            If e.Item.Checked = True Then
                For i = 0 To txtAlertType.Items.Count() - 1
                    txtAlertType.Items(i).Checked = True
                Next
            Else
                For i = 0 To txtAlertType.Items.Count() - 1
                    txtAlertType.Items(i).Checked = False
                Next
            End If

        Case "Custom Alerts"
            If e.Item.Checked = True Then
                For i = 0 To txtAlertType.Items.Count() - 1
                    If txtAlertType.Items(i).value < 14 And txtAlertType.Items(i).value > 0 Then
                        txtAlertType.Items(i).Checked = True
                    End If
                Next
            Else
                txtAlertType.Items(0).Checked = False
                For i = 0 To txtAlertType.Items.Count() - 1
                    If txtAlertType.Items(i).value < 14 And txtAlertType.Items(i).value > 0 Then
                        txtAlertType.Items(i).Checked = False
                    End If
                Next
            End If
        Case "Cash Management"
            If e.Item.Checked = True Then
                For i = 0 To txtAlertType.Items.Count() - 1
                    If txtAlertType.Items(i).value > 15 Then
                        txtAlertType.Items(i).Checked = True
                    End If
                Next
            Else
                txtAlertType.Items(0).Checked = False
                For i = 15 To txtAlertType.Items.Count() - 1
                    If txtAlertType.Items(i).value > 15 Then
                        txtAlertType.Items(i).Checked = True
                    End If
                Next
            End If
    End Select

End Sub
4

2 回答 2

0

这就是我最终做的事情:

<telerik:RadComboBox ID="txtAlertType" Runat="server" Visible="False" OnClientItemChecked="OnClientDropDown"
                    Width="205px" AutoPostBack="True" CheckBoxes="True"  DropDownCssClass="multipleRowsColumns"
                    EnableAutomaticLoadOnDemand="True" DropDownWidth="400px">

function OnClientDropDown(sender, eventArgs) {
    if (eventArgs.get_item().get_text() == "Custom Alerts") {
        var Combo = $find("<%=txtAlertType.ClientID %>");
        var items = Combo.get_items();
        var i = 2;
        if (items._array[i].get_checked()) {
            var combo = $find("<%= txtAlertType.ClientID %>");
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            combo.trackChanges();
            combo.get_items().getItem(1).check();
            combo.get_items().getItem(3).check();
            combo.get_items().getItem(4).check();
            combo.get_items().getItem(6).check();
            combo.get_items().getItem(8).check();
            combo.get_items().getItem(10).check();
            combo.get_items().getItem(12).check();
            combo.get_items().getItem(14).check();
            combo.get_items().getItem(16).check();
            combo.get_items().getItem(18).check();
            combo.get_items().getItem(20).check();
            combo.get_items().getItem(22).check();
            combo.get_items().getItem(24).check();
            combo.commitChanges();
        } else {
           var combo = $find("<%= txtAlertType.ClientID %>");
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            combo.trackChanges();
            combo.get_items().getItem(1).uncheck();
            combo.get_items().getItem(3).uncheck();
            combo.get_items().getItem(4).uncheck();
            combo.get_items().getItem(6).uncheck();
            combo.get_items().getItem(8).uncheck();
            combo.get_items().getItem(10).uncheck();
            combo.get_items().getItem(12).uncheck();
            combo.get_items().getItem(14).uncheck();
            combo.get_items().getItem(16).uncheck();
            combo.get_items().getItem(18).uncheck();
            combo.get_items().getItem(20).uncheck();
            combo.get_items().getItem(22).uncheck();
            combo.get_items().getItem(24).uncheck();
            combo.commitChanges();
        }
    }

    if (eventArgs.get_item().get_text() == "Cash Management") {
        var Combo = $find("<%=txtAlertType.ClientID %>");
        var items = Combo.get_items();
        var i = 5;
        if (items._array[i].get_checked()) {
            var combo = $find("<%= txtAlertType.ClientID %>");
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            combo.trackChanges();
            combo.get_items().getItem(7).check();
            combo.get_items().getItem(9).check();
            combo.get_items().getItem(11).check();
            combo.get_items().getItem(13).check();
            combo.get_items().getItem(15).check();
            combo.get_items().getItem(17).check();
            combo.get_items().getItem(19).check();
            combo.get_items().getItem(21).check();
            combo.get_items().getItem(23).check();
            combo.get_items().getItem(25).check();
            combo.commitChanges();
        } else {
            var combo = $find("<%= txtAlertType.ClientID %>");
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            combo.trackChanges();
            combo.get_items().getItem(7).uncheck();
            combo.get_items().getItem(9).uncheck();
            combo.get_items().getItem(11).uncheck();
            combo.get_items().getItem(13).uncheck();
            combo.get_items().getItem(15).uncheck();
            combo.get_items().getItem(17).uncheck();
            combo.get_items().getItem(19).uncheck();
            combo.get_items().getItem(21).uncheck();
            combo.get_items().getItem(23).uncheck();
            combo.get_items().getItem(25).uncheck();
            combo.commitChanges();
        }
    }

    if (eventArgs.get_item().get_text() == "Check All") {
        var Combo = $find("<%=txtAlertType.ClientID %>");
        var items = Combo.get_items();
        var i = 0;
        if (items._array[i].get_checked()) {
            var combo = $find("<%= txtAlertType.ClientID %>");
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            combo.trackChanges();
            combo.get_items().getItem(1).check();
            combo.get_items().getItem(2).check();
            combo.get_items().getItem(3).check();
            combo.get_items().getItem(4).check();
            combo.get_items().getItem(6).check();
            combo.get_items().getItem(8).check();
            combo.get_items().getItem(10).check();
            combo.get_items().getItem(12).check();
            combo.get_items().getItem(14).check();
            combo.get_items().getItem(16).check();
            combo.get_items().getItem(18).check();
            combo.get_items().getItem(20).check();
            combo.get_items().getItem(22).check();
            combo.get_items().getItem(24).check();
            combo.get_items().getItem(5).check();
            combo.get_items().getItem(7).check();
            combo.get_items().getItem(9).check();
            combo.get_items().getItem(11).check();
            combo.get_items().getItem(13).check();
            combo.get_items().getItem(15).check();
            combo.get_items().getItem(17).check();
            combo.get_items().getItem(19).check();
            combo.get_items().getItem(21).check();
            combo.get_items().getItem(23).check();
            combo.get_items().getItem(25).check();
            combo.commitChanges();
        } else {
            var combo = $find("<%= txtAlertType.ClientID %>");
            var comboItem = new Telerik.Web.UI.RadComboBoxItem();
            combo.trackChanges();
            combo.get_items().getItem(1).uncheck();
            combo.get_items().getItem(2).uncheck();
            combo.get_items().getItem(3).uncheck();
            combo.get_items().getItem(4).uncheck();
            combo.get_items().getItem(6).uncheck();
            combo.get_items().getItem(8).uncheck();
            combo.get_items().getItem(10).uncheck();
            combo.get_items().getItem(12).uncheck();
            combo.get_items().getItem(14).uncheck();
            combo.get_items().getItem(16).uncheck();
            combo.get_items().getItem(18).uncheck();
            combo.get_items().getItem(20).uncheck();
            combo.get_items().getItem(22).uncheck();
            combo.get_items().getItem(24).uncheck();
            combo.get_items().getItem(5).uncheck();
            combo.get_items().getItem(7).uncheck();
            combo.get_items().getItem(9).uncheck();
            combo.get_items().getItem(11).uncheck();
            combo.get_items().getItem(13).uncheck();
            combo.get_items().getItem(15).uncheck();
            combo.get_items().getItem(17).uncheck();
            combo.get_items().getItem(19).uncheck();
            combo.get_items().getItem(21).uncheck();
            combo.get_items().getItem(23).uncheck();
            combo.get_items().getItem(25).uncheck();
            combo.commitChanges();
        }
    }
}
于 2013-06-25T00:53:13.620 回答
0

听起来您很适合新的 Telerik RadTreeList。您还可以查看我的自定义控件RadComboTree

允许您的用户使用 RadDropDownTree for ASP.NET AJAX 轻松浏览分层数据列表中的大量项目。利用各种数据绑定选项,使用二十种内置皮肤之一或通过模板轻松自定义控件。请放心,该控件可以在任何浏览器和设备上运行。

在此处输入图像描述

于 2013-06-24T21:10:13.717 回答