Rad Combobox with ItemTemplate is not calling the OnSelectedIndexChanged server side event handler.

1 posts, 0 answers
  1. Samar Hamdan
    Samar Hamdan avatar
    5 posts
    Member since:
    Aug 2009

    Posted 19 Sep 2010 Link to this post

    Dears,
    me and my team colleagues have faced a very strange issue withthe RadComboBox with items bouded in ItemTemplate controls,
    Our UI design Case is:
    we have a radComboBox with items bouded into ItemTemplate controls in the server side with a datasource of
    Lookup type (Key, Value). This rad combobox is placed in a rad update panel and set to autopostback = true.
    It has another dependent comboboxes should be filtered on each user closing of the combobox with his/her checked items.
    The item template contains ASP checkBox represents the data text and a hidden field represents the data Key.
    After the user check some of the comboBox checkboxes and leave this control out, a client side function is called to collect the user checked items and show them in the combobox Text as comma separeated string. in addition, the combobox when is autopostback true should be notified that the user has selectedItemChanged so that the server side event (onSelectedIndexChanged) should be called after each user closig of the combobox control.
    The Problem is:
    The server side event is not called all the time after leaving the combobox. we supposed that the combobox know that the selectedIndexChanged when we write (comboBoxClientObj.set_selectedItem(0);) or any similier code re set the selected item in the client side so that firing the server side event.
    Unfortuanitly, the server side onSelectedIndexChanged is not called on checking the Text#1, while called on all other cases !!
    Our Code related part:
    * on .ASCX

    <

     

    telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

     

    <script type="text/javascript">

     

    function CheckAll_CCRLoadChartFilter_Location() {

     

    var chkboxs_Location = Chart_CCRLoadChartFilter_CheckBoxsLocation_IDs.split(",");

     

     

    for (var i = 0; i < chkboxs_Location.length - 1; i++) {

     

     

            if (document.getElementById(chkboxs_Location[i]) != null) {

            document.getElementById(chkboxs_Location[i]).checked = document.getElementById(chkboxs_Location[0]).checked;

            }

        }

     

    }

     

    function RemoveCheckAll_CCRLoadChartFilter_Location() {

     

     

    var chkboxs_Location = Chart_CCRLoadChartFilter_CheckBoxsLocation_IDs.split(",");

     

     

    var d = $find("<%= ddlLocation.ClientID %>")

    d.set_selectedItem(0)

    document.getElementById(chkboxs_Location[0]).checked =

     

    false;

    }

     

     

    function SetTextOfTheLocationComboBox_CCRLoadChartFilter(sender, eventArgs) {

     

     

    var chkboxsLocation = Chart_CCRLoadChartFilter_CheckBoxsLocation_IDs.split(",");

     

     

    var selectedLocation = "";

     

     

    for (var i = 0; i < chkboxsLocation.length - 1; i++) {

     

     

    var chkedItemLocation = document.getElementById(chkboxsLocation[i]);

     

     

    var chkedItem_All_Location = document.getElementById(chkboxsLocation[0]);

     

     

    if (chkedItemLocation != null && chkedItemLocation.checked) {

     

     

    if (chkedItem_All_Location != null && chkedItem_All_Location.checked) {

    selectedLocation = chkedItem_All_Location.nextSibling.firstChild.data;

    sender.set_text(selectedLocation);

     

    return;

    }

    selectedLocation = selectedLocation + chkedItemLocation.nextSibling.firstChild.data +

    ",";

     

    }

    }

     

    if (selectedLocation == "")

    selectedLocation =

     

    "..."

     

    else {

    document.getElementById(

     

    "<%= tdLocation.ClientID %>").title = selectedLocation;

     

     

    if (selectedLocation.length > 25) {

    selectedLocation = selectedLocation.substring(0, 22) +

     

    "...";

    }

    }

     

    sender.set_text(selectedLocation);

    }

     

     

    function SetTextOfTheLocationComboBox_CCRLoadChartFilter_Close(sender, eventArgs) {

     

     

    var chkboxsLocation = Chart_CCRLoadChartFilter_CheckBoxsLocation_IDs.split(",");

     

     

    var selectedLocation = "";

     

     

    for (var i = 0; i < chkboxsLocation.length - 1; i++) {

     

     

    var chkedItemLocation = document.getElementById(chkboxsLocation[i]);

     

     

    var chkedItem_All_Location = document.getElementById(chkboxsLocation[0]);

     

     

    if (chkedItemLocation != null && chkedItemLocation.checked) {

     

     

    if (chkedItem_All_Location != null && chkedItem_All_Location.checked) {

    selectedLocation = chkedItem_All_Location.nextSibling.firstChild.data;

    sender.set_text(selectedLocation);

     

    return;

    }

    selectedLocation = selectedLocation + chkedItemLocation.nextSibling.firstChild.data +

     

    ",";

    }

    }

     

    if (selectedLocation == "")

    selectedLocation =

     

    "..."

     

    else {

    document.getElementById(

     

    "<%= tdLocation.ClientID %>").title = selectedLocation;

     

     

    if (selectedLocation.length > 25) {

    selectedLocation = selectedLocation.substring(0, 22) +

     

    "...";

    }

    }

     

    sender.set_text(selectedLocation);

    }

     

     

    </script>

    </

     

    telerik:RadScriptBlock>

     

     

    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel11">

     

    <table width="235px" dir="rtl" style="text-align: left">

     

    <tr>

     

        <td>

     

            <telerik:RadComboBox Width="100%" ID="ddlLocation" runat="server" Skin="Office2007"

     

            MaxHeight="150px" AutoPostBack="true" CausesValidation="false" OnItemDataBound="ddlLocation_ItemDataBound"

     

            OnClientSelectedIndexChanged="SetTextOfTheLocationComboBox_CCRLoadChartFilter_Close"  OnSelectedIndexChanged="ddlLocation_OnSelectedIndexChanged"

     

            OnClientLoad="SetTextOfTheLocationComboBox_CCRLoadChartFilter">

     

                <ItemTemplate>

     

                    <asp:CheckBox ID="chkDropLocationItem_CCRLoadChartFilter" AutoPostBack="false" Checked="true"

     

                            runat="server" Text='<%# Eval("Value")%>' />

     

                    <asp:HiddenField ID="hdnDropLocationItem_CCRLoadChartFilter" runat="server" Value='<%# Eval("Key")%>' />

     

                </ItemTemplate>

     

                <CollapseAnimation Type="OutQuint" Duration="0"></CollapseAnimation>

     

            </telerik:RadComboBox>

     

        </td>

     

    </tr>

     

    </table>

    </

     

    telerik:RadAjaxPanel>

     

     

    * on .CS

     

    protected override void OnPreRender(EventArgs e)

     {

     

     

     

    ScriptManager.RegisterClientScriptBlock(this.Page, typeof(Page), "Register_CCRLoadChart_checkBoxsLocation_ID", "<script> var Chart_CCRLoadChartFilter_CheckBoxsLocation_IDs='" + CheckBoxesLocationIds + "';</script>", false);

     

     

    base.OnPreRender(e);

    }

     

     

    protected void Page_Load(object sender, EventArgs e)

    {

     

        if (!this.IsPostBack)

        {

        FillLocationLookup();

     

        }  

     

     

    }

     

     

    protected

     

    void ddlLocation_ItemDataBound(object sender, RadComboBoxItemEventArgs e)

     

     {

     

     

    CheckBox chk = e.Item.FindControl("chkDropLocationItem_CCRLoadChartFilter") as CheckBox;

     

     

    if (chk != null)

    {

     

    if (e.Item.Index == 0)

    chk.Attributes[

    "onClick"] = "CheckAll_CCRLoadChartFilter_Location()";

     

     

    else

     

     

    chk.Attributes[

    "onClick"] = "RemoveCheckAll_CCRLoadChartFilter_Location()";

     

     

    if (!CheckBoxesLocationIds.Contains(chk.ClientID))

    CheckBoxesLocationIds += chk.ClientID +

     

    ",";

    }

    }

     

     

    protected void ddlLocation_OnSelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)

    {

     

    List<String> selectedLocation = new List<String>();

     

     

    foreach (RadComboBoxItem item in ddlLocation.Items)

    {

     

    CheckBox chk = item.FindControl("chkDropLocationItem_CCRLoadChartFilter") as CheckBox;

     

     

    HiddenField hdnField = item.FindControl("hdnDropLocationItem_CCRLoadChartFilter") as HiddenField;

     

     

    if (chk != null && hdnField != null && chk.Checked && !String.IsNullOrEmpty(hdnField.Value))

    {

     

    if (hdnField.Value == Constants.AllLocation_Key)

    {

    selectedLocation.Add(

     

    Constants.AllLocation_Key);  

     

     

    break;

    }

     

    else

     

     

    {

    selectedLocation.Add(hdnField.Value);

    }

    }

    }

    FilterParameters filterParameters = (((IAdvanceSearch)Page).Parameters);  

     

     

    List<string> courts = filterParameters.Courts; ;

     

    CourtNodeTree courtNameTree = FiltersManager.CurrentUserCourtNodeTree.GetCourtNameTree(courts.ToArray());

     

     

    List<LookupItem> lookupCourtType = new List<LookupItem>();

     

     

    string[] classification = new string[1];

    classification[0] = filterParameters.Classificaton;

    lookupCourtType = courtNameTree.GetCourtTypeNodes(selectedLocation.ToArray(), classification);

     

    if (lookupCourtType.Count > 0)

    {

    lookupCourtType.Sort(

     

    new LookupItemComparer());

    lookupCourtType.Insert(0,

     

    new LookupItem(Constants.AllCourtsType_Key, Constants.AllCourtsType_Value));

    FillDropDown(lookupCourtType, ddlCourtType);

    }

     

    else

     

     

    {

    ddlCourtType.Items.Clear();

    ddlCourtType.ClearSelection();

    }

    }

    yours comments and fix will be highly apprieciated,

    Regards,
    Samar hamdan.





Back to Top