get slider item index from value on clientside

3 posts, 0 answers
  1. paddy
    paddy avatar
    6 posts
    Member since:
    Feb 2008

    Posted 29 Jul 2010 Link to this post

    Hi all,

    I am trying to get the index value of a slider item when I know what the value of the item is.

    i have a range slider where itemtype = item and i have set the items as such
    <Items>
                <telerik:RadSliderItem Text="D" Value="1" ToolTip="D" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="E" Value="2" ToolTip="E" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="F" Value="3" ToolTip="F" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="G" Value="4" ToolTip="G" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="H" Value="5" ToolTip="H" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="I" Value="6" ToolTip="I" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="J" Value="7" ToolTip="J" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="K" Value="8" ToolTip="K" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="L" Value="9" ToolTip="L" runat="server"></telerik:RadSliderItem>
                <telerik:RadSliderItem Text="M" Value="10" ToolTip="M" runat="server"></telerik:RadSliderItem>
            </Items>

    In javascript i receive the value for the item and I am trying to set the selectionStart and selectionEnd to these passed in values.

    I have tried several various techniques to no avail, my current attempt was to use

    var newMinValueIndex = ValueSlider._getIndexFromValue(newMinValue);
    ValueSlider.set_selectionStart(newMinValueIndex);

    to set the selectionStart value.

    but I am getting strange results where
    the index for 1 is 0 which is correct
    the index for 2 is 0.5 which is incorrect
    the index for 3 is 1 which is incorrect
    etc

    am I using the wrong technique or is there a better way for me to set the sliders when I know the value of the items but not their position within the sliders.

    Thanks in advance

    Paddy
  2. paddy
    paddy avatar
    6 posts
    Member since:
    Feb 2008

    Posted 30 Jul 2010 Link to this post

    I have a working solution for this problem.

    newMinClarity = arrClarity[0];
    newMaxClarity = arrClarity[1];
    var
    ClarityItems = ClaritySlider.get_items();
            //var tempVal = '';
            for (var i = 0; i < ClarityItems.length; ++i) {
                tempVal = ClarityItems[i];
                if (newMinClarity == tempVal.get_value()) {
                    newMinClarityIndex = i;
                    break;
                }
            }
      
            for (var i = 0; i < ClarityItems.length; ++i) {
                tempVal = ClarityItems[i];
                if (newMaxClarity == tempVal.get_value()) {
                    newMaxClarityIndex = i;
                    break;
                }
            }
      
                ClaritySlider.set_selectionStart(newMinClarityIndex);
                ClaritySlider.set_selectionEnd(newMaxClarityIndex);


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. msigman
    msigman avatar
    141 posts
    Member since:
    Apr 2008

    Posted 21 Jan 2011 Link to this post

    I found there is a tiny delay when changing the value and when the value is actually changed on the HTML element.  Introducting a 50ms delay using setTimeout() worked fine for us.

    setTimeout('$find("<%=RadSlider1.ClientID %>").get_value();', 50);
Back to Top