How to Uncheck checkbox from client side?

3 posts, 1 answers
  1. Rafael
    Rafael avatar
    15 posts
    Member since:
    Jun 2013

    Posted 27 Jan 2014 Link to this post

    Hi,
    How can I uncheck checkbox from client side? I am using the control without the " Check/Uncheck All " option. I need know how I verify if the args item is checked or not.

    Here is my RadListBox:
    <telerik:RadListBox ID="rlUsers" runat="server" CheckBoxes="true" AutoPostBack="false" SelectionMode="Single" Width="300" OnItemDataBound="rlUsers_ItemDataBound" OnDataBound="rlUsers_DataBound"                OnClientItemChecked="OnClientItemChecked" ></telerik:RadListBox>

    function OnClientItemChecked(sender, args) {
                    var aux = args.get_item(sender);
                    var items = sender.get_items();
                    items.forEach(function (itm) { itm.set_checked(false); });
                    aux.set_checked(true);
                }

    Below is my pseudo-code that show what I want to do:
    function OnClientItemChecked(sender, args) {
                   var aux = args.get_item(sender);
                   if(aux.checked == false){
                              var items = sender.get_items();
                              items.forEach(function (itm) { itm.set_checked(false); });
                              aux.set_checked(true);
                    }
                }

    How I do : if(aux.checked == false) in javascript in this case?
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Jan 2014 in reply to Rafael Link to this post

    Hi Rafael,

    Please try get_checked() property to know whether an item is checked or not as follows.

    JavaScript:
    <script type="text/javascript">
        function OnClientItemChecked(sender, args) {
            var aux = args.get_item(sender);
            if (aux.get_checked() == false) {
                var items = sender.get_items();
                items.forEach(function (itm) { itm.set_checked(false); });
                aux.set_checked(true);
            }
        }
    </script>

    Hope this will helps you.
    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rafael
    Rafael avatar
    15 posts
    Member since:
    Jun 2013

    Posted 28 Jan 2014 in reply to Princy Link to this post

    Thanks Princy! ;-)
    Works!
Back to Top