Eric Wallace
Top achievements
Rank 1
Eric Wallace
asked on 29 Nov 2010, 07:26 PM
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?5 Answers, 1 is accepted
0
Eric Wallace
Top achievements
Rank 1
answered on 29 Nov 2010, 11:08 PM
I think there may be an indexer out of place. If I do:
Problem is, I have to go off of the value, not the zero-based index.
$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 optionProblem is, I have to go off of the value, not the zero-based index.
0
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:
Greetings,
Tsvetie
the Telerik team
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.
0
Eric Wallace
Top achievements
Rank 1
answered on 13 Dec 2010, 03:54 PM
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
Thanks,
Eric
0
Eric Wallace
Top achievements
Rank 1
answered on 13 Dec 2010, 04:09 PM
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.
0
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
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.