Insert a check uncheck all button.

2 posts, 0 answers
  1. Damian
    Damian avatar
    21 posts
    Member since:
    Mar 2013

    Posted 17 Jul 2013 Link to this post

    Hi

    I want to insert a Check All and UnCheck All Item in radlistbox. On Checking all items the item should change to UnCheck All. I tried some code found in net, but that was not changing the item.

    Thanks
    Damian.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Jul 2013 Link to this post

    Hi Damian,

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

    ASPX:
    <telerik:RadListBox ID="RadListBox1" runat="server" CheckBoxes="true" OnClientItemChecked="OnClientItemChecked">
        <Items>
            <telerik:RadListBoxItem runat="server" Text="Check All" />
            <telerik:RadListBoxItem runat="server" Text="Item 1" />
            <telerik:RadListBoxItem runat="server" Text="Item 2" />
            <telerik:RadListBoxItem runat="server" Text="Item 3" />
        </Items>
    </telerik:RadListBox>

    JavaScript:
    <script type="text/javascript">
        function OnClientItemChecked(sender, args) {
            var item = args.get_item();
            var items = sender.get_items();
            if (item.get_text() == "Check All") {
                if (item.get_checked()) {
                    for (var counter = 0; counter < items.get_count(); counter++) {
                        items.getItem(counter).set_checked(true);
                    }
                }
                else {
                    for (var counter = 0; counter < items.get_count(); counter++) {
                        items.getItem(counter).set_checked(false);
                    }
                }
            }
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top