Disabled items

6 posts, 1 answers
  1. Andreas Selling
    Andreas Selling avatar
    20 posts
    Member since:
    May 2009

    Posted 22 Sep 2009 Link to this post

    Hello

    I have a slider where i can select a number from 0-5. If I disable one of these items it is still possible to select it. Even If I set the element to visible=false it is still selecteble just that the layout get mixed upp.

    I just want it grayed out and non selecteble. If I try to select it or drag it to that number it will just go back to its previous position.
    Is this possible?
  2. Answer
    Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 23 Sep 2009 Link to this post

    Hello Andreas Selling,

    For the time being, the only way you can get this behavior is to implement it with code. For example:

    <script type="text/javascript"
    function OnClientBeforeValueChange(sender, args) 
        var itemToBeSelected = sender.get_items()[args.get_newValue()]; 
        if(!itemToBeSelected.get_enabled()) 
            args.set_cancel(true); 
    </script> 
     
    <telerik:RadSlider ID="RadSlider1" runat="server" ItemType="Item" Height="60px" TrackPosition="BottomRight" 
        OnClientBeforeValueChange="OnClientBeforeValueChange"
        <Items> 
            <telerik:RadSliderItem Text="0" Value="0" /> 
            <telerik:RadSliderItem Text="1" Value="1" /> 
            <telerik:RadSliderItem Text="2" Value="2" Enabled="false" /> 
            <telerik:RadSliderItem Text="3" Value="3" /> 
            <telerik:RadSliderItem Text="4" Value="4" /> 
            <telerik:RadSliderItem Text="5" Value="5" /> 
        </Items> 
    </telerik:RadSlider> 

    Regards,
    Tsvetie
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andreas Selling
    Andreas Selling avatar
    20 posts
    Member since:
    May 2009

    Posted 24 Sep 2009 Link to this post

    Thanks, is this something you are working on to be improved?
  5. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 25 Sep 2009 Link to this post

    Hi Andreas Selling,
    This is on our TODO list for the RadSlider control, but I cannot give you a precise estimate when we will implement it. What I can tell you, is that it will not be part of the Q3 2009 release as the tasks for the Q have already been set and this one is not a part of the list.

    Greetings,
    Tsvetie
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Taiseer
    Taiseer avatar
    37 posts
    Member since:
    Oct 2007

    Posted 17 Jan 2012 Link to this post

    Hello,

    Currently I'm using Telerik 2011 Q3, did Telerik manage to find out of the box solution for this?
    The client side function OnClientBeforeValueChange is not supported in my version.
    What i'm trying to do is to disable certain items and allow the user to use the Increase and Decrease handles so the drag handle jumps over disbaled items to the next enabled item.
  7. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 20 Jan 2012 Link to this post

    Hello Taiseer,

    The client-side event OnClientBeforeValueChange of the RadSlider is deprecated in the Q3 2011 release of the RadControls for ASP.NET AJAX. You can use OnClientValueChanging instead, as it allows you to cancel the sliding of the drag handle if it is moved to a disabled RadSlider item. Also I have modified the code of the event handler a bit in order to implement the jumping over disabled items:

    <script type="text/javascript">
        function OnClientValueChanging(sender, args) {
            var newValue = args.get_newValue();
            var oldValue = args.get_oldValue();
            var direction = (newValue > oldValue) ? 1 : -1;
            var itemToBeSelected = sender.get_items()[newValue];
            if (!itemToBeSelected.get_enabled()) {
                args.set_cancel(true);
                sender.set_value(newValue + direction);
            }
        }
    </script>
    <telerik:RadSlider ID="RadSlider1" runat="server" ItemType="Item" Height="60px" TrackPosition="BottomRight"
        OnClientValueChanging="OnClientValueChanging">
        <Items>
            <telerik:RadSliderItem Text="0" Value="0" />
            <telerik:RadSliderItem Text="1" Value="1" />
            <telerik:RadSliderItem Text="2" Value="2" Enabled="false" />
            <telerik:RadSliderItem Text="3" Value="3" Enabled="false" />
            <telerik:RadSliderItem Text="4" Value="4" />
            <telerik:RadSliderItem Text="5" Value="5" />
        </Items>
    </telerik:RadSlider>

    Regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017