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

Disabled items

5 Answers 80 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Andreas Selling
Top achievements
Rank 2
Andreas Selling asked on 22 Sep 2009, 03:12 PM
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?

5 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetie
Telerik team
answered on 23 Sep 2009, 08:51 AM
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.
0
Andreas Selling
Top achievements
Rank 2
answered on 24 Sep 2009, 08:35 PM
Thanks, is this something you are working on to be improved?
0
Tsvetie
Telerik team
answered on 25 Sep 2009, 06:02 AM
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.
0
Taiseer
Top achievements
Rank 1
answered on 17 Jan 2012, 02:56 PM
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.
0
Slav
Telerik team
answered on 20 Jan 2012, 10:09 AM
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
Tags
Slider
Asked by
Andreas Selling
Top achievements
Rank 2
Answers by
Tsvetie
Telerik team
Andreas Selling
Top achievements
Rank 2
Taiseer
Top achievements
Rank 1
Slav
Telerik team
Share this question
or