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

Slider does not adapt to container width change

8 Answers 1172 Views
Slider
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 25 Jan 2012, 07:33 PM
Hello,

I am using the slider within a container that resizes as the browser window is resized. The slider does not adapt to the new width, and I don't see a method to redraw it.

Can you provide some guidance on how this can be resolved?

Thanks,
Gary

8 Answers, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 30 Jan 2012, 09:21 AM
Hello Gary,

Dynamic resizing of the slider is currently unsupported. The way to resolve this is to re-initialize the slider, by destroying it first ($("#slider-container").empty()) and initializing it again, with the same configuration. We are looking for a more graceful solution of this problem, but for now, use this approach.

Regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Katarina
Top achievements
Rank 1
answered on 26 May 2012, 05:16 AM
I use Kendo with jQuery and this is how i resize elements (for now).

Example:
$(this.element).closest('p').find('.pickup_date').empty().width(149).kendoDatePicker({ animation: false, format: "MM/dd/yyyy" });


Here is my full prototype function:
function onChange(e) {
     
    switch (this.value())
    {
        case "range":
            $(this.element).closest('p').children('label').hide();
            $(this.element).closest('.section-content').find('.pickup_date_range_addition').show();
            $(this.element).closest('p').find('.pickup_date').empty().width(149).kendoDatePicker({ animation: false, format: "MM/dd/yyyy" });
            break;
             
        default:
            $(this.element).closest('p').children('label').show();
            $(this.element).closest('.section-content').find('.pickup_date_range_addition').hide();
            $(this.element).closest('p').find('.pickup_date').empty().width(185).kendoDatePicker({ animation: false, format: "MM/dd/yyyy" });
            break;
    }
     
}
 
$(".kdropdown").kendoDropDownList({ animation: false, change: onChange });
0
Devi
Top achievements
Rank 1
answered on 04 Sep 2012, 01:38 PM
Hi

I dont see the slider dynamic resize is supported in the latest version of kendo. Please let me know if it is to be released in the next version.

thanks
swathi
0
Jason
Top achievements
Rank 1
answered on 25 Feb 2013, 11:58 PM
I using this code to set the width initially and it works. But I call the same code on a window resize event and it does nothing. It doesn't resize the slider even though it writes tot eh console the correct width to resize it.

var width = $('#rangeColumn').width();
console.log('width = '+width);
 
$('input[type="range"]').empty().width(width+'px').kendoSlider({showButtons:false,tickPlacement:'none'}); // initialize or resize all sliders

Any idea why the its not working. Am I calling .empty() on the wrong element?

Thanks,
Jason
0
Alex Gyoshev
Telerik team
answered on 26 Feb 2013, 09:45 AM
Hello Jason,

Yes, input elements are always empty, because they do not have any children. You need to clean the container of the slider element, i.e. some element that contains the slider.

Greetings,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jason
Top achievements
Rank 1
answered on 26 Feb 2013, 11:16 PM
Thanks Alex. That helped me create this function which is working for me.

Do you see any problems with resizing using this method?

Thanks,
Jason
function resizeRange(element, width, config) {
    var element = $(element);
    var slider = element.parent().parent();
    var parent = slider.parent();
    parent.append(element);
    slider.remove();
    element.width(width).kendoSlider(config);
    element.parent().parent().show(); // not sure why its hidden
}
 
// calling it
resizeRange('#ageRange', '100px', {showButtons:false, tickPlacement:'none'});

0
Alex Gyoshev
Telerik team
answered on 27 Feb 2013, 11:04 AM
I am not sure what you are trying to achieve. Can you please reproduce it in a jsbin sample? Here's a basic one with a slider to get you started.

Kind regards,
Alex Gyoshev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
JohnVS
Top achievements
Rank 1
answered on 18 Sep 2014, 07:09 PM
For anyone coming around to this post years later, like I did, you can update the width of a RangeSlider by using this code from the documentation:

$(document).ready(function() {
    $("#rangeslider").kendoRangeSlider();
    var rangeSlider = $("#rangeslider").getKendoRangeSlider();
    rangeSlider.wrapper.css("width", "400px");
    rangeSlider.resize();
});
Tags
Slider
Asked by
Gary
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Katarina
Top achievements
Rank 1
Devi
Top achievements
Rank 1
Jason
Top achievements
Rank 1
JohnVS
Top achievements
Rank 1
Share this question
or