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

Mutually Exclusive Checkbox

2 Answers 203 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Mohammed Imaduddin
Top achievements
Rank 1
Mohammed Imaduddin asked on 29 Apr 2010, 09:31 PM
Does anyone know if there is a way to get a Mutually Exclusive Checkbox with this listbox control. Like the one available thru the Ajax Toolkit?

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Apr 2010, 11:48 AM

Hello Mohammed,

You can achieve the same functionality by using client-side API of RadListBox control.

Attach the OnClientItemChecked event to RadListBox and check/uncheck the corresponding item after getting reference the item. Use the findItemByText/findItemByValue/findItemByAttribute methods for getting reference to corresponding item. Then use the set_checked() method to check/uncheck the item.

Hope the following links would be helpfull for you:

Client-side Basics

RadListBox client API

-Shinu.

0
William
Top achievements
Rank 1
answered on 10 Jul 2014, 05:24 PM
I don't know about findItemByText/findItemByValue/findItemByAttribute BUT for those who's looking for a quick fix.  Here it is.

function rlboxRoles_ItemChecked(sender, args) {
        var listbox = sender;
        var items = listbox.get_items();
        var count = items.get_count();
        var checkedItem = args.get_item();
        var index = items.indexOf(checkedItem);
        for (var i = 0; i < count; i++) {
            if (i != index) {
                items.getItem(i).set_checked(false);
            }
            else {
                items.getItem(i).set_checked(true);
            }
        }
    }
Tags
ListBox
Asked by
Mohammed Imaduddin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
William
Top achievements
Rank 1
Share this question
or