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

Insert a check uncheck all button.

1 Answer 11 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Damian
Top achievements
Rank 1
Damian asked on 17 Jul 2013, 06:38 PM
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.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 18 Jul 2013, 03:40 AM
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.
Tags
ListBox
Asked by
Damian
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or