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

RadComboBox with checkboxes

6 Answers 129 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
berto
Top achievements
Rank 1
berto asked on 19 Aug 2012, 09:35 AM
I implemented this successfully, i have only issue with error handling if no checkbox will be checked. Any suggestions how the easiest I can solve this issue?

6 Answers, 1 is accepted

Sort by
0
Nencho
Telerik team
answered on 20 Aug 2012, 08:22 AM
Hello Adnrej,

Could you elaborate a bit more about the scenario you are trying to achieve? Do you mean to implement a validation if there are no items checked in RadComboBox?


Regards,
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.
0
berto
Top achievements
Rank 1
answered on 20 Aug 2012, 01:58 PM
Yes, this is exactly what I need. I have to be sure that at least one item will be checked.
0
Nencho
Telerik team
answered on 21 Aug 2012, 11:52 AM
Hello Andrzej,

In order to implement the desirable validation, you could perform a verification if there are any items checked with the client method get_checkedItems of the RadComboBox object, or you could check if the CheckedItems.Count is greater than 0 at server side. Please consider the following approach implemented at client side, at the event handler of an RadButton, considering there are two RadComboBoxes to validate:
function onClientClicked() {
            var noErrors = true;
            var label = document.getElementById("label");
            for (i = 0; i < 2; i++) {
 
                if (Telerik.Web.UI.RadComboBox.ComboBoxes[i].get_checkedItems().length < 1) {
                    noErrors = false;
                }
            }
            if (!noErrors)
                label.textContent = "Fill all RadComboBoxes";
            else
                label.textContent = "";
        }

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.
0
Matt
Top achievements
Rank 1
answered on 24 Jul 2013, 06:55 PM
I'm trying to use JQuery to get the value of a specific checkbox but I can't find any documentation for get_checkedItems() for a RadComboBox anywhere.

Could you post a working link to it??
0
A2H
Top achievements
Rank 1
answered on 24 Jul 2013, 08:46 PM
Hello,

Please use the below code to find checked items of combobox in client side

var $ = $telerik.$;
 
function validate(sender, eventArgs)
{
        var combo = $find("<%= RadComboBox3.ClientID %>");
        if (combo.get_checkedItems().length < 1) {
      alert("Please select atleast one item");
     }
}


For reference please check the below link
1) ClientSide Basics
2) RadComboBox Object


Thanks,
A2H
0
A2H
Top achievements
Rank 1
answered on 24 Jul 2013, 08:49 PM
Hello,

Please use the below code snippet to find the checked items in combobox on client side

var $ = $telerik.$;
            function validate(sender, eventArgs) {
                var combo = $find("<%= RadComboBox3.ClientID %>");
                if (combo.get_checkedItems().length < 1) {
                    alert("Please select atleast one item");
                }
            }


Please refer this link for reference

Thanks,
A2H
Tags
ComboBox
Asked by
berto
Top achievements
Rank 1
Answers by
Nencho
Telerik team
berto
Top achievements
Rank 1
Matt
Top achievements
Rank 1
A2H
Top achievements
Rank 1
Share this question
or