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

Check Box Issue

3 Answers 25 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
: Arumuga Vignesh
Top achievements
Rank 1
: Arumuga Vignesh asked on 30 Jul 2013, 06:34 AM
Hi,

I have six checkboxes inside telerik combobox control .  On  checking the first checkbox, I have to disable second and third one.

Similarly, on checking fifth checkbox I have to disable sixth one. I tried using  onitemchecked,autopostback =true  and onclientitemchecked  events but couldn’t get the result.

Please help with the sample code

Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 30 Jul 2013, 11:39 AM
Hi Arumuga,

Please have a look into the sample code I tried which works fine at my end.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" CheckBoxes="true" OnClientItemChecked="OnClientItemChecked">
    <Items>
        <telerik:RadComboBoxItem runat="server" Text="Item 1" />
        <telerik:RadComboBoxItem runat="server" Text="Item 2" />
        <telerik:RadComboBoxItem runat="server" Text="Item 3" />
        <telerik:RadComboBoxItem runat="server" Text="Item 4" />
        <telerik:RadComboBoxItem runat="server" Text="Item 5" />
        <telerik:RadComboBoxItem runat="server" Text="Item 6" />
    </Items>
</telerik:RadComboBox>

JavaScript:
<script type="text/javascript">
    function OnClientItemChecked(sender, args) {
        //accessing the clicked item.
        var item = args.get_item();
        if (item.get_index() == 0) {
            //Checking whether its the first item, then index will be zero.
            if (item.get_checked()) {
                //Disabling the second and third item.
                sender.get_items().getItem(1).set_enabled(false);
                sender.get_items().getItem(2).set_enabled(false);
            }
            else {
                sender.get_items().getItem(1).set_enabled(true);
                sender.get_items().getItem(2).set_enabled(true);
            }
        }
        else if (item.get_index() == 4) {
            if (item.get_checked()) {
                sender.get_items().getItem(5).set_enabled(false);
            }
            else {
                sender.get_items().getItem(5).set_enabled(true);
            }
        }
    }
</script>

Thanks,
Shinu.
0
: Arumuga Vignesh
Top achievements
Rank 1
answered on 08 Aug 2013, 10:08 AM

Hi,
I have a combo box with checkboxes. OnClientItemChecked and OnClientDropDownClosed I have written a javascript like below.

 

function OnClientItemChecked(sender, eventArgs)

{    

    var comboBox = $find("<%=rbcmbDemoStatus.ClientID %>");

    var item = eventArgs.get_item();

    

    if(comboBox.get_items().getItem(0).get_checked())

    {                  

    sender.get_items().getItem(1).set_enabled(false);

    sender.get_items().getItem(2).set_enabled(false);

    }    

    else if(comboBox.get_items().getItem(1).get_checked())

    {    

    sender.get_items().getItem(0).set_enabled(false);

    sender.get_items().getItem(2).set_enabled(false);

    }        

}

 

It worked fine when I called this javascript from aspx itself. But when I moved the javascript to separate script.js file,

It is throwing error like sender undefined.

 

This is calling event:

 

<telerik:RadComboBox ID="rbcmbDemoStatus" runat="server" CheckBoxes="true" Width="160" OnClientItemChecked="OnClientItemChecked" OnClientDropDownClosed="OnClientDropDownClosed" Skin="Office2007">

I called the script like this:

 

<script type="text/javascript" src="~/Scripts/JCO Scripts.js"></script>

<script language ="javascript" type ="text/javascript">

OnClientItemChecked(sender, eventArgs)

</script>

0
Shinu
Top achievements
Rank 1
answered on 08 Aug 2013, 12:45 PM
Hi Arumuga,

Please try with the following code in your external JS.

JavaScript:
function OnClientItemChecked(sender, eventArgs) {
    var item = eventArgs.get_item();
    if (sender.get_items().getItem(0).get_checked()) {
        sender.get_items().getItem(1).set_enabled(false);
        sender.get_items().getItem(2).set_enabled(false);
    }
    else if (sender.get_items().getItem(1).get_checked()) {
        sender.get_items().getItem(0).set_enabled(false);
        sender.get_items().getItem(2).set_enabled(false);
    }
}
 
Also please have a look at this forum thread which deals with a similar scenario.

Thanks,
Shinu.
Tags
General Discussions
Asked by
: Arumuga Vignesh
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
: Arumuga Vignesh
Top achievements
Rank 1
Share this question
or