使用多选RadComboBox时如何避免在ItemSelected上回发?

时间:2013-07-10 19:39:02

标签: webforms telerik radcombobox

我有以下情况:

<%-- UF --%>
<tr>
    <td>
        <label>UF</label>
        <br />
        <telerik:RadComboBox ID="rcbUF" runat="server" CheckBoxes="True" EnableCheckAllItemsCheckBox="True" CausesValidation="false"
            Culture="pt-BR" CssClass="lt-width-10" MaxHeight="250" OnItemChecked="rcbUF_ItemChecked" AutoPostBack="true">
        </telerik:RadComboBox>
    </td>
</tr>
<%-- Rodovia --%>
    <tr>
        <td>
            <label>Rodovia</label>
            <br />
            <asp:UpdatePanel runat="server" ID="uppRodovia">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="rcbUF" />
                </Triggers>
                <ContentTemplate>
                    <telerik:RadComboBox ID="rcbRodovia" runat="server" CheckBoxes="True" EnableCheckAllItemsCheckBox="True" Culture="pt-BR" MaxHeight="250" CssClass="lt-width-10" />
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
    </tr>

在rcbUF上检查项目时,会调用以下方法(类似的方法):

protected void rcbUF_ItemChecked(object sender, RadComboBoxItemEventArgs e)
{
if (rcbUF.HasSelectedValue())
{
    var _listaUF = rcbUF.Items.Where(x => x.Checked).Select(x => x.Value).ToList();
    var _rodovias = Repositorio<Rodovia>.GetAll.Where(x => x.ListaUF.Any(y=>_listaUF.Contains(y.UF.Id))).Select(x => x.Id).ToArray();

    if (_listaUF.Count > 0)
    {
        rcbRodovia.Carregar<Rodovia>(x => x.Numero, x => x.Id,
            Constantes.TextoVazioEspaco,
            true,
            x => _rodovias.Contains(x.Id),
            x => x.Numero);
    }
    else
    {
        rcbRodovia.Carregar<Rodovia>(x => x.Numero, x => x.Id,
            Constantes.TextoVazioEspaco,
            true,
            x => x.Numero);
    }

    rcbRodovia.Items.Distinct();
    rcbRodovia.Enabled = true;
}
}

我的问题是,每当我点击项目而不是复选框时,它会触发回发(很多关于OnItemSelected的方式),我真的不希望它发生。

我在这里遗漏了什么,或者只是预期的行为而没有办法绕过它?

1 个答案:

答案 0 :(得分:1)

停止回发的正确方法是

<telerik:RadComboBox ID="rd1" runat="server" OnClientSelectedIndexChanging="OnClientSelectedIndexChanging" AutoPostBack="true">
<Items>
<telerik:RadComboBoxItem Text="1001" />
<telerik:RadComboBoxItem Text="2001" />
<telerik:RadComboBoxItem Text="3001" />
<telerik:RadComboBoxItem Text="4001" />
<telerik:RadComboBoxItem Text="5001" />
<telerik:RadComboBoxItem Text="6001" />
</Items>
</telerik:RadComboBox>

       function OnClientSelectedIndexChanging(sender, args) 
       {
          args.set_cancel(true); 
       }

由于