Can't retrieve value

14 posts, 0 answers
  1. Voss Grose
    Voss Grose avatar
    81 posts
    Member since:
    Sep 2012

    Posted 09 Jan 2009 Link to this post

    I have the following RadSlider which is in a UserControl:
            <telerik:RadSlider runat="server" ID="rsVery" EnableViewState="false" Orientation="Horizontal" Width="500" Height="50" TrackPosition="TopLeft" Skin="Inox" ItemType="Item" MinimumValue="-10" MaximumValue="10" SmallChange="1" ShowDecreaseHandle="true" ShowIncreaseHandle="true" Visible="true" AnimationDuration="250">
                <Items>
                    <telerik:RadSliderItem Text="Very Slow" Value="-3" ToolTip="Very Slow" runat="server"></telerik:RadSliderItem>
                    <telerik:RadSliderItem Text="Slow" Value="-2" runat="server"></telerik:RadSliderItem>
                    <telerik:RadSliderItem Text="Normal" Value="0" runat="server"></telerik:RadSliderItem>
                    <telerik:RadSliderItem Text="Fast" Value="2" runat="server"></telerik:RadSliderItem>
                    <telerik:RadSliderItem Text="Very Fast" Value="3" runat="server"></telerik:RadSliderItem>
                </Items>
            </telerik:RadSlider>        


    The .Value just returns the position index.

    can you tell me what I'm doing wrong..

    thanks



  2. cbospikes
    cbospikes avatar
    16 posts
    Member since:
    May 2007

    Posted 10 Jan 2009 Link to this post

    I used the following to find the value server side

    Dim sli As RadSlider = TryCast(item.FindControl("rslider"), Telerik.Web.UI.RadSlider)
    Dim value As Integer = sli.Value
    Dim routsegid As String = sli.Items(value).Value.ToString()

    use the slider value (index) to get the selected slideritem.  Then get the value of the item.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 12 Jan 2009 Link to this post

    Hi,
    Yes, this is the correct way to obtain the value of the currently selected item of the RadSlider. By design, when you have items in the RadSlider, the slider itself can accept values from 0 to the number of the items minus 1. We made this on purpose, so that the developers have more flexibility and can define sliders like the following one:
    <telerik:RadSlider ID="MonthsSlider" runat="server" Orientation="Vertical" Skin="SkyBlue" 
        Height="417px" Width="100px" CssClass="monthsSlider" ItemType="Item" TrackPosition="TopLeft" 
        Value="5" OnClientValueChange="MonthChange"
        <Items> 
            <telerik:RadSliderItem Text="January" Value="Jan" /> 
            <telerik:RadSliderItem Text="February" Value="Feb" /> 
            <telerik:RadSliderItem Text="March" Value="Mar" /> 
            <telerik:RadSliderItem Text="April" Value="Apr" /> 
            <telerik:RadSliderItem Text="May" Value="May" /> 
            <telerik:RadSliderItem Text="June" Value="Jun" /> 
            <telerik:RadSliderItem Text="July" Value="Jul" /> 
            <telerik:RadSliderItem Text="August" Value="Aug" /> 
            <telerik:RadSliderItem Text="September" Value="Sep" /> 
            <telerik:RadSliderItem Text="October" Value="Oct" /> 
            <telerik:RadSliderItem Text="November" Value="Nov" /> 
            <telerik:RadSliderItem Text="December" Value="Dec" /> 
        </Items> 
    </telerik:RadSlider> 

    Greetings,
    Tsvetie
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Terry Brown
    Terry Brown avatar
    3 posts
    Member since:
    May 2006

    Posted 26 Mar 2009 Link to this post

    I understand your reasoning for doing this (it certainly does allow us to be more flexible) though I wonder at your omission of a

    Slider.SelectedItem as a public property that acts as a wrapper for

    slider.Items[slider.Value]

    So rather than in code having to do:

    sldSlider1.Items[sldSlider1.Value].Value

    I can just do:

    sldSlider1.SelectedItem.Value

    it's elegance really, functionally it makes little difference, but aesthetically in code and logically I think it's better?

    that said, if there is already something like this, please ignore the post - I just haven't managed to find it.

    Cheers,
    Terry
  6. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 30 Mar 2009 Link to this post

    Hello Terry,
    There is such a server property - SelectedItems, however, it is not implemented yet. We will do our best to implement it for the SP, scheduled for this week.

    All the best,
    Tsvetie
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  7. Tony Isaac
    Tony Isaac avatar
    3 posts
    Member since:
    May 2009

    Posted 20 May 2009 Link to this post

    So how do you get the value client-side?

    I want a label next to the slider to show the selected value as the user slides the slider.  This takes to long if it has to be done server-side.  I see in the generated HTML that the LI tags do not have any reference to the values, only the indexes.  Is there a way around this?
  8. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 21 May 2009 Link to this post

    Hello Tony Isaac,
    You can get the value of a slider item on the client in a similar manner as on the server:
    function GetItemValue()   
    {   
        var slider = $find('<%= RadSlider1.ClientID %>');   
        var selectedItem = slider.get_items()[slider.get_value()];   
        alert(selectedItem.get_value());   
    }   
     

    All the best,
    Tsvetie
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. Tony Isaac
    Tony Isaac avatar
    3 posts
    Member since:
    May 2009

    Posted 22 May 2009 Link to this post

    Voss,

    Thank you for your response.  However, the code you suggested gets only the numeric index of the slider position, not the value of that index.  In the code below, I want the text for each item, not the numeric index.

     

    <telerik:RadSlider ID="RadSlider" runat="server" MaximumValue="7" 
    Width="300px" Height="22px" Length="300" ItemType="Tick" onclientslide="OnSlide" >
    <Items>
    <telerik:RadSliderItem runat="server" Text="Not Set" Value="Not Set" />
    <telerik:RadSliderItem runat="server" Text="Very unhappy"  Value="Very unhappy" /> 
    <telerik:RadSliderItem runat="server" Text="Unhappy" Value="Unhappy" /> 
    <telerik:RadSliderItem runat="server" Text="Somewhat unhappy"  Value="Somewhat unhappy" /> 
    <telerik:RadSliderItem runat="server" Text="Neutral" Value="Neutral" /> 
    <telerik:RadSliderItem runat="server" Text="Somewhat satisfied"  Value="Somewhat satisfied" /> 
    <telerik:RadSliderItem runat="server" Text="Satisfied" Value="Satisfied" /> 
    <telerik:RadSliderItem runat="server" Text="Very satisfied" Value="Very satisfied" /> 
    </Items
    </telerik:RadSlider>

    Tony

  10. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 22 May 2009 Link to this post

    Hi Tony Isaac,
    In case you need to text of a slider item, you should use the get_text method:
    function GetItemValue()    
    {    
        var slider = $find('<%= RadSlider1.ClientID %>');    
        var selectedItem = slider.get_items()[slider.get_value()];    
        alert(selectedItem.get_text());    
    }   


    Regards,
    Tsvetie
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  11. Tony Isaac
    Tony Isaac avatar
    3 posts
    Member since:
    May 2009

    Posted 22 May 2009 Link to this post

    Thank you again for your quick response.  However, we still don't have a solution.  The get_text() method still only returns the index number:

                function OnSlide()  
                {  
                    var slider = $find('<%= RadSlider.ClientID %>');  
                    var selectedItem = slider.get_items()[slider.get_value()];  
                    document.getElementById('GoodFeeling').innerText = selectedItem.get_text();  
                }  
     

    Tony
  12. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 25 May 2009 Link to this post

    Hi Tony Isaac,
    I am not quite sure what you mean by index number. When I run the provided code for the following RadSlider, I get January, February, March, etc:
    <script type="text/javascript"
        function OnSlide(sender, args)   
        {   
            var slider = sender;   
            var selectedItem = slider.get_items()[slider.get_value()];   
            document.getElementById('GoodFeeling').innerText = selectedItem.get_text();   
        }  
    </script> 
     
    <div id="GoodFeeling"
    </div> 
    <telerik:RadSlider ID="RadSlider1" runat="server" ItemType="Item" Width="700px" Height="70px" 
        TrackPosition="BottomRight" OnClientSlide="OnSlide"
        <Items> 
            <telerik:RadSliderItem Text="January" Value="Jan" /> 
            <telerik:RadSliderItem Text="February" Value="Feb" /> 
            <telerik:RadSliderItem Text="March" Value="Mar" /> 
            <telerik:RadSliderItem Text="April" Value="Apr" /> 
            <telerik:RadSliderItem Text="May" Value="May" /> 
            <telerik:RadSliderItem Text="June" Value="Jun" /> 
            <telerik:RadSliderItem Text="July" Value="Jul" /> 
            <telerik:RadSliderItem Text="August" Value="Aug" /> 
            <telerik:RadSliderItem Text="September" Value="Sep" /> 
            <telerik:RadSliderItem Text="October" Value="Oct" /> 
            <telerik:RadSliderItem Text="November" Value="Nov" /> 
            <telerik:RadSliderItem Text="December" Value="Dec" /> 
        </Items> 
    </telerik:RadSlider> 

    As I am not sure which version of the assembly you use, I tested with the latest - 2009.1.402.

    In case this does not help you, please prepare and send me a simple running project, demonstrating the problem as well as detailed information on the expected result.

    Best wishes,
    Tsvetie
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  13. Josh
    Josh  avatar
    10 posts
    Member since:
    Nov 2013

    Posted 03 Nov in reply to Tsvetie Link to this post

    slider.get_items is undefined.  Has something changed?   How can I get the current text of the item at the specified index?

    I've isolated this demo, 

    http://demos.telerik.com/aspnet-ajax/slider/examples/clientsideevents/defaultvb.aspx?show-source=true

    I changed javascript code as follows:   It does not work.

            rangeSliderValueChanging: function (sender, args) {
                var newValue = args.get_newValue();
                var isFirstHandleActive = getActiveDragHandle(sender);

                var slider = sender;
                var selectedItem = slider.get_items()[slider.get_value()];
                alert(selectedItem.get_text());

            },

     

  14. Josh
    Josh  avatar
    10 posts
    Member since:
    Nov 2013

    Posted 03 Nov in reply to Josh Link to this post

    To be clear, the current selected index is returned just fine. Its the get_items() that does not work. Returns an empty array.
  15. Josh
    Josh  avatar
    10 posts
    Member since:
    Nov 2013

    Posted 03 Nov in reply to Josh Link to this post

    To be clear, I can get the index ok. Its the get_items() that returns an empty array.
  16. Josh
    Josh  avatar
    10 posts
    Member since:
    Nov 2013

    Posted 03 Nov Link to this post

    I found the problem. You must explicitly assign the ItemType property to "Item" for it to work.  Even though its the default as far as I can tell. Issue resolved.  Thanks.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017