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

Preventing Transfer of Disabled Items

2 Answers 116 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Stuart Hemming
Top achievements
Rank 2
Stuart Hemming asked on 17 Aug 2010, 05:06 PM
I have 2 ListBoxes. If an item in one ListBox is disabled I need to stop it from being transferred to the other.

I've already established that I need to limit the buttons to remove the TransferAll... options in an attempt to achieve this.

With only the TransferTo and TransferFrom buttons working it appears that you can stop the transfer of disabled items 'cos you can't select 'em, but no...

If I select an item above the disabled item and transfer it to the other ListBox, the source ListBox automatically selects the next item down in the list whether or not it is disabled". Similarly, if the disabled item is at the top of the list and I transfer all of the other items in the ListBox, the disabled item is selected when it is the remaining item and it can be transferred.

Now, I personally think that having the system select a disabled item automagically is a bug. If it's not and this functionality is by design, can I request a new property on the ListBox; AllowDisabledItemTransfer. If you set the default to true then the existing functionality will remain unchanged.

-- 
Stuart

2 Answers, 1 is accepted

Sort by
0
Stuart Hemming
Top achievements
Rank 2
answered on 17 Aug 2010, 05:59 PM
For any readers, there is a workaround.

If you haven't got any automatic postbacks happening on your ListBoxes then you only need wire in the client-side event OnClientSelectedIndexChanging like this... 
<script type="text/javascript">
    function SelectedIndexChanging(sender, args)
    {
        if (!args.get_item().get_enabled())
        {
            args.set_cancel(true);
        }
    }
</script>

If, on the other hand you have got one of the postback options enabled you need to wire up the server-side event OnPreRender and add this or something like it ...
protected void ListBox_PreRender(object sender, EventArgs e)
{
    RadListBoxItem item = (sender as RadListBox).SelectedItem;
    if(item != null && !item.Enabled) {
        item.Selected = false;
    }
}

The chances are, you'll need both.

I still think that the ListBox, in this respect, is broken, but at least there's a way around the problem.
-- 
Stuart

0
Accepted
Genady Sergeev
Telerik team
answered on 20 Aug 2010, 02:11 PM
Hello Stuart Hemming,

We have fixed this bug with respect to the client-side, the latest release should work fine. However, the bug still exists when server-side transfer is used. The issue is already logged into our bug-tracking system and we will try to get it resolved as soon as possible.

Sincerely yours,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ListBox
Asked by
Stuart Hemming
Top achievements
Rank 2
Answers by
Stuart Hemming
Top achievements
Rank 2
Genady Sergeev
Telerik team
Share this question
or