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

[Solved] change width of MVC Slider

5 Answers 274 Views
Slider
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kris Nobels
Top achievements
Rank 2
Kris Nobels asked on 26 Apr 2011, 01:49 PM
Hello,

In the slider of the Ajax version it's possible to change the width of the slider.

How can i do this for the MVC slider ?

5 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Germanov
Telerik team
answered on 26 Apr 2011, 02:42 PM
Hi Kris Nobels,

Thank you for contacting us.

You need to set the width of the input that will turn into the slider.

Html:

<input id="slider" type="range" style="width: 300px;" />

JavaScript:
$("#slider").tSlider();

All the best,

Hristo Germanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Accepted
Marino
Top achievements
Rank 1
answered on 15 Jul 2011, 01:23 PM
Okay, this works. :-) But by setting the width with jQuery I was unable to set other options (e.g. Orientation).

Is the only way to set the width (or height for my Vertically oriented slider) by jQuery? I would expect to set it in MVC code too. Here's my code:
<%= Html.Telerik().Slider<int>()           
                    .Name("mySlider")
                    .Value(2)
                    .Min(1)
                    .Max(3)
                    .Orientation(SliderOrientation.Vertical)
                    .TickPlacement(SliderTickPlacement.None)
                    .Tooltip(false)
                    .ClientEvents(events => events                     
                        .OnSlide("onSlideValue")                     
                        .OnChange("onChangeValue"))
                    .HtmlAttributes(new { height = "120", @class = "profileSlider" })
            %>

By the way, setting the height in the HtmlAttribute didn't work. Also when I set the height property to "120px" it will become "120" in the created INPUT element.

Hope you can help me out.
0
Dino
Top achievements
Rank 1
answered on 14 Sep 2011, 07:22 PM
I have tried the to set the height of my vertical slider using the HtmlAttibutes of the slider inside my .cshtml.

I also tried to modify the Areas/Razor/Views/Slider/FirstLook.cshtml in the example project to the following and it still doesn't adjust the size of the slider.

@(Html.Telerik().Slider<double>()
              .Name("Slider")
              .Min(Model.SliderAttributes.MinValue.Value)
              .Max(Model.SliderAttributes.MaxValue.Value)
              .SmallStep(Model.SliderAttributes.SmallStep.Value)
              .LargeStep(Model.SliderAttributes.LargeStep.Value)
              .Orientation(Model.SliderAttributes.SliderOrientation.Value)
              .ShowButtons(Model.SliderAttributes.ShowButtons.Value)
              .Value(Model.SliderAttributes.Value)
              .HtmlAttributes(new { width = "120px"})
        )

It seems this only modifies the invisible input associated with the slider...
Am I missing something???

0
Dimo
Telerik team
answered on 15 Sep 2011, 09:10 AM
Hello,

Please bear in mind that width and height are obsolete HTML attributes and the Slider does not take them into account. You should use style.

.HtmlAttributes(new { style = "width:120px"})

All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Dino
Top achievements
Rank 1
answered on 16 Sep 2011, 03:43 PM
Doh! How did I not see that... Must have forgotten to have my coffee that morning... :) Thanks!!!
Tags
Slider
Asked by
Kris Nobels
Top achievements
Rank 2
Answers by
Hristo Germanov
Telerik team
Marino
Top achievements
Rank 1
Dino
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or