This is a migrated thread and some comments may be shown as answers.

Combobox check all issues

3 Answers 34 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Krishna
Top achievements
Rank 1
Krishna asked on 18 Jun 2015, 01:26 PM

Hi Team,

I have a combo box like this and client function as shown below. 

   <telerik:RadComboBox ID="cmbCurrency" runat="server" CausesValidation="false"  ClientIDMode="AutoID"
                    EmptyMessage="[Select All]" Filter="Contains" MaxHeight="150" Width="100%" HighlightTemplatedItems="true" 
                    AllowCustomText="true"  OnClientDropDownClosed="onDropDownClosing"> 
                     <ItemTemplate>  
                        <div onclick="StopPropagation(event)" >  
                            <asp:CheckBox runat="server" ID="cbxItem" Text='<%# Eval("CurrencyCode") %>' onclick="onCheckBoxClick(this,'cmbCurrency')"/>   
                        </div>  
                    </ItemTemplate>  
                </telerik:RadComboBox>

 

//<Combo box 2  with same onclick event > 

 

Onclick Event:

 function onCheckBoxClick(chk, val) {
                var combo = $find("ctl00_MainContent_radDockSelection_C_ctl00_" + val);

                        //prevent second combo from closing 
                cancelDropDownClosing = true;
                //holds the text of all checked items 
                var text = "";
                //get the collection of all items 
                var items = combo.get_items();
                for (var i = 0; i < items.get_count(); i++) {
                    var item = items.getItem(i);
                    //get the checkbox element of the current item 
                    var chk1 = $get(combo.get_id() + "_i" + 0 + "_cbxItem");
                    var chk2 = $get(combo.get_id() + "_i" + i + "_cbxItem");

                    if (chk.nextSibling.innerHTML != "[Select All]") {
                        chk1.checked = false;
                        if (chk2.checked == true)
                            text += chk2.nextSibling.innerHTML + ", ";
                    }
                    else {
                        if (chk1.checked == true)
                            text = "[Select All]";
                        chk2.checked = false;
                        chk1.checked = true;
                    }


                }
                text = removeLastComma(text);

                if (text.length > 0) {
                    //set the text of the combobox   
                    combo.set_text(text);
                    combo.ToolTip = text;
                }

            }

There were 2 problems

1) Check boxes was not responsive.i.e they are not allowing to check either. I change clientstateId as AutoId then It worked.
2) Check all seems not working. 

 

Please let me know How to fix this.

 

Note : the code recently migrated to dotnet 4 and hosted in windows 2008 r2 .

 

Thanks in Advance.

 

Krish

 

 

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Krishna
Top achievements
Rank 1
answered on 22 Jun 2015, 10:22 AM

The exact issue with the above code is :

chk2.checked = false;
                        chk1.checked = true;

 

is not working. How to check /uncheck check boxes dyanamically?

 

 

0
Krishna
Top achievements
Rank 1
answered on 22 Jun 2015, 01:09 PM

I dont know how these forums are really useful

I have posted a query 3 days ago.Still no answer.

Is this the way telerik support works?

 

0
Krishna
Top achievements
Rank 1
answered on 22 Jun 2015, 01:17 PM

I could see all answers answered after around 4 days delay,Forcing the user to find their own solution.

Nice way to encourage self learning though! Excellent!

 

Tags
ComboBox
Asked by
Krishna
Top achievements
Rank 1
Answers by
Krishna
Top achievements
Rank 1
Share this question
or