selected text is missing in dropdownlist

4 posts, 0 answers
  1. Aewin
    Aewin  avatar
    19 posts
    Member since:
    Aug 2011

    Posted 22 Apr 2013 Link to this post

    Hi Telerik Team,


    Good Morning.

    I use two dropdownlists,multiple checkboxes are included in each dropdownlist, and second dropdownlist check box data must be changed accordingly to the selection of first dropdownlist check box data.


    When I click frist dropdownlist and nothing do changes but second drop downlist selected data is missing although its checkboxes are still selected.


    Please check my attached powerpoint.

    Regards,
    Aewin.



  2. Nencho
    Admin
    Nencho avatar
    1822 posts

    Posted 24 Apr 2013 Link to this post

    Hello Aewin,

    Would you provide us with the implementation of the related controls, in order to inspect the faced issue locally and troubleshoot it for you?


    All the best,
    Nencho
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. Aewin
    Aewin  avatar
    19 posts
    Member since:
    Aug 2011

    Posted 25 Apr 2013 Link to this post

      <telerik:RadCodeBlock runat="server" ID="RadCodeBlock1">
            <script type="text/javascript">
                var id = null;
                var LoadRole;
                var Department_ID = null;
                var JobRole_ID = null;

               
                function pageLoad() {
                    // initialize the global variables
                    // in this event all client objects 
                    // are already created and initialized 

                    var panelbar = $find("<%= RadPanelBar1.ClientID %>");
                    var item = panelbar.findItemByText("Step 3:Roles");
                    LoadRole = item.findControl("cboRole");
                }

        
                function LoadRole(sender, eventArgs) {
                    var chk_text = sender.get_text();
                    var combo = sender;
                    var items = combo.get_items();
                    var itemCount = items.get_count();

                    var n = chk_text.split(",");
                    var n_count = n.length;

                    if (n_count == 1) {
                        for (var counter = 0; counter < itemCount; counter++) {
                            var item = items.getItem(counter);
                            var item_text = item.get_text();
                            if (chk_text == item_text) {
                                item.set_checked(true)
                            }
                            else {
                                item.set_checked(false)
                            }
                        }
                    }

                    var i = 0;
                    var q = "";
                    while (i < sender._itemData.length) {
                        q += sender._itemData[i].checked ? sender._itemData[i].value : "";
                        if (i + 1 < sender._itemData.length) {
                            if (sender._itemData[i].checked) {
                                q += ",";
                            }
                        }
                        i++;
                    }

                    LoadRole.clearItems();

                    // if a continent is selected
                    if (q != "") {
                        // this will fire the ItemsRequested event of the 
                        // industryType combobox passing the industrySectorID as a parameter 
                        LoadRole.requestItems(q, false);
                    }
                    else {
                        // the -Select an Industry Sector- item was chosen
                        LoadRole.clearItems();
                    }
                }

                function LoadDepartmentIDCheckedItems(sender, e) {

                    var chk_text = sender.get_text();
                    var combo = sender;
                    var items = combo.get_items();
                    var itemCount = items.get_count();

                    var n = chk_text.split(",");
                    var n_count = n.length;

                    if (n_count == 1) {
                        for (var counter = 0; counter < itemCount; counter++) {
                            var item = items.getItem(counter);
                            var item_text = item.get_text();
                            if (chk_text == item_text) {
                                item.set_checked(true)
                            }
                            else {
                                item.set_checked(false)
                            }
                        }
                    }

                    var i = 0;
                    var q = "";
                    while (i < sender._itemData.length) {
                        q += sender._itemData[i].checked ? sender._itemData[i].value : "";
                        if (i + 1 < sender._itemData.length) {
                            if (sender._itemData[i].checked) {
                                q += ",";
                            }
                        }
                        i++;
                    }
                    var hidden = document.getElementById('<%=hidRoleIDs.ClientID %>');
                    hidden.value = q;
    //                var hidden_d = document.getElementById('<%=hidDepartmentIDs.ClientID %>');
    //                hidden_d.value = q;
                }

            
               

                // to set checked to item checkbox sndh
                function OnClientDropDownClosedHandler(sender, eventArgs) {

                    var chk_text = sender.get_text();
                    var combo = sender;
                    var items = combo.get_items();
                    var itemCount = items.get_count();

                    var n = chk_text.split(",");
                    var n_count = n.length;

                    if (n_count == 1) {
                        for (var counter = 0; counter < itemCount; counter++) {
                            var item = items.getItem(counter);
                            var item_text = item.get_text();
                            if (chk_text == item_text) {
                                item.set_checked(true)
                            }
                            else {
                                item.set_checked(false)
                            }
                        }
                    }
                }

               
            </script>
        </telerik:RadCodeBlock>

    ---------------------------------------------------------------------------------------------------------------------------------------------
    .CS file

    protected void cboRole_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {
            // e.Text is the first parameter of the requestItems method 
            // invoked in LoadIndustryType method 
            Response.Write(e.Text);
            txtTest.Text = e.Text;
            BindRole(e.Text);
            
        }

     protected void BindRole(string DepartmentID)
        {
           // txtTest.Text = DepartmentID;
            Response.Write("BindRole");
            hidDepartmentIDs.Value = DepartmentID;

            //hidDepartmentIDs.Value is missing after postback
            
            if (DepartmentID != null && DepartmentID != "")
            {
                RadComboBox cboRole = (RadComboBox)RadPanelBar1.FindItemByValue("Role").FindControl("cboRole");
                Role role = new Role();
            
                RadComboBox cboCompanyName = (RadComboBox)RadPanelBar1.FindItemByValue("Registration").FindControl("cboCompanyName");

                role.orgID = orgID;
                role.companyID = cboCompanyName.SelectedValue;
                role.department = DepartmentID;


                cboRole.DataSource = role.GetRoleListByCompanyID();
                cboRole.DataTextField = "roleTitle";
                cboRole.DataValueField = "sysKey";
                cboRole.DataBind();

                check_bind_Combobox(hidRoleIDs.Value, cboRole);
            }
        }
        
        protected void ShowData()

  4. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 30 Apr 2013 Link to this post

    Hello Aewin,

    I tested your code, but it seems to be working. When I select items from the second combo they are added to the combo's input. I'm attaching my testing sample. Please check it out and let me know if I have missed something.

    All the best,
    Hristo Valyavicharski
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top