Hello,
I have a radcombobox with an ItemTemplate that contains a checkbox and a label.
| <telerik:RadComboBox ID="cbM0016" runat="server" |
| EmptyMessage="Select Branch" HighlightTemplatedItems="true" |
| AllowCustomText="true" Enabled="false" Skin="Outlook" Width="100%" > |
| <ItemTemplate> |
| <asp:CheckBox runat="server" ID="chk1" Checked="true" onclick="onCheckBoxClickM0016(this)"/> |
| <asp:Label runat="server" ID="lbl1" Text='<%#DataBinder.Eval(Container.DataItem, "BranchNameAndID")%>'/> |
| </ItemTemplate> |
| </telerik:RadComboBox> |
One of the checkboxes (the "ALL" checkbox) will trigger all other checkboxes to be checked and store all the associated values as a comma delimited string. This is being done in the javascript. The problem I'm having is that occasionally my values are not being posted back to the server.
Repro steps are:
Load the form (default selection works fine)
Unselelct several checkboxes and submit the form (works fine)
Select the "ALL" checkbox (form does not submit the updated values)
I have added alerts in the javascript that show that the values are being set on the client side. Here is that code...
| function onCheckBoxClickM0016(sender) { |
| var combo = $find("<%= cbM0016.ClientID %>"); |
| //holds the text of all checked items |
| var text = ""; |
| //holds the values of all checked items |
| var values = ""; |
| //get the collection of all items |
| var items = combo.get_items(); |
| //get the ALL checkbox |
| var chk1 = $get(combo.get_id() + "_i0" + "_chk1"); |
| if (chk1.checked && sender.id == "cbM0016_i0_chk1") { |
| text = "ALL"; |
| //enumerate all items |
| for (var i = 1; i < items.get_count(); i++) { |
| var item = items.getItem(i); |
| //get the checkbox element of the current item |
| var chk2 = $get(combo.get_id() + "_i" + i + "_chk1"); |
| chk2.checked = true; |
| values += item.get_value() + ","; |
| } |
| } |
| else { |
| var count = 0; |
| //enumerate all items |
| for (var i = 1; i < items.get_count(); i++) { |
| var item = items.getItem(i); |
| //get the checkbox element of the current item |
| var chk2 = $get(combo.get_id() + "_i" + i + "_chk1"); |
| if (chk2.checked) { |
| count += 1; |
| text += item.get_text() + ","; |
| values += item.get_value() + ","; |
| } |
| } |
| if (count == i - 1 && sender.id != "cbM0016_i0_chk1") { |
| chk1.checked = true; |
| } |
| else { |
| chk1.checked = false; |
| } |
| } |
| //remove the last comma from the string |
| text = removeLastComma(text); |
| values = removeLastComma(values); |
| if (text.length > 0) { |
| //set the text of the combobox |
| if (chk1.checked) { |
| combo.set_text("ALL"); |
| } else { |
| combo.set_text(text); |
| } |
| } |
| else { |
| //all checkboxes are unchecked |
| //so reset the controls |
| combo.set_text(""); |
| } |
| combo.set_value(values); |
| } |
Please help.
-Billy