Preventing Transfer of Disabled Items

3 posts, 1 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 17 Aug 2010 Link to this post

    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. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 17 Aug 2010 Link to this post

    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

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 20 Aug 2010 Link to this post

    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
Back to Top