Is this a bug?

6 posts, 0 answers
  1. Eric Wallace
    Eric Wallace avatar
    17 posts
    Member since:
    Oct 2009

    Posted 29 Nov 2010 Link to this post

    If you take the following code:
    <telerik:Radslider id="slider2" runat="server" itemtype="Item" skin="Windows7" Height="40px">
      <Items>
        <telerik:RadSliderItem Value="1" Text="One" />
        <telerik:RadSliderItem Value="2" Text="Two" />
        <telerik:RadSliderItem Value="3" Text="Three" />
      </Items>
    </telerik:Radslider>
    <script type="text/javascript">
    $(document).ready(function()
    {
      $find('<%= slider2.ClientID %>').set_value(2);
    });
    </script>

    and run it in a browser, it actually sets the slider to Item 3, not 2 as specified.
    Is this a known issue or am I missing something here?
  2. Eric Wallace
    Eric Wallace avatar
    17 posts
    Member since:
    Oct 2009

    Posted 29 Nov 2010 Link to this post

    I think there may be an indexer out of place. If I do:
      $find('<%= slider2.ClientID %>').set_value(0)
    - it selects the first option
      $find('<%= slider2.ClientID %>').set_value(1) - it selects the second option
      $find('<%= slider2.ClientID %>').set_value(2) - it selects the third option

    Problem is, I have to go off of the value, not the zero-based index.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 02 Dec 2010 Link to this post

    Hello Eric Wallace,
    The behavior you describe is expected. Basically, in the case of an items slider, the Value property of the slider specifies (gets and sets) the selected item index. Currently, RadSlider only provides methods to get the selectedItem(s)/selectedValue of the currently selected item. In order to implement the functionality you describe, you can use the client-side API of RadSlider to find the item by value and then set it as selected item. For example:

    var slider = $find('<%= slider2.ClientID %>')
     
    var itemValue = 2;
    var items = slider.get_items();
     
    var index = items.length;
    while(--index && (items[index].get_value() != itemValue)){}
     
    if(index)
        slider.set_value(index);


    Greetings,
    Tsvetie
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  5. Eric Wallace
    Eric Wallace avatar
    17 posts
    Member since:
    Oct 2009

    Posted 13 Dec 2010 Link to this post

    Thanks for your help, Tsvetie. I'm curious as to why the documentation for the slider control does not state that set_value actually sets the selected index. That is extremely confusing terminology.If an item's value is 1, and I call set_value(1), I would expect the item with the value of 1 to be selected. Maybe a set_selectedIndex(idx) function would be more appropriate for future versions?

    Thanks,
    Eric
  6. Eric Wallace
    Eric Wallace avatar
    17 posts
    Member since:
    Oct 2009

    Posted 13 Dec 2010 Link to this post

    It should also be noted that get_value() returns the selected index as well, not the value of the selected item as one would expect.
  7. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 16 Dec 2010 Link to this post

    Hello Eric Wallace,
    RadSlider has three modes - numeric slider, items slider and ticks slider. In all three modes, the Value property stands for the value of the slider control itself. In case you have noticed, the Value of a slider item is of type String, whereas the Value property of the slider control is of type Decimal. That is why, it is simply not possible for the Value property of the slider control to return the value of the selected item. You are correct that it as an omission for our part, that we have not explained this in the documentation. I will log it in our ToDo list.

    Regarding getting the value of the selected item, you can use the get_selectedValue method.

    Kind regards,
    Tsvetie
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017