Last Updated: 17 Jan 2019 10:10 by ADMIN
Created on: 17 Jan 2019 09:57
Category: ColorPicker
Type: Bug Report
Error when only HSB or HSV pallette is used and when RadColorPicker is added during partial rendering - Sys.ArgumentOutOfRangeException: Height should be an integer bigger than 1

When a RadColorPicker that only has the HSB or HSV palette is made visible or added during an AJAX request, it throws the following error:

Sys.ArgumentOutOfRangeException: Height should be an integer bigger than 1

This is caused by the lack of dimensions while the component is initializing on the client side and, for example, RGBSliders, manages to initialize correctly. The control must either have default dimensions for all modes, or to perform check for undefined dimensions provided by the browser, or both.

A workaround is to add the RGBSliders mode as the first mode so the control can initialize, and use a small JS handler that will switch to the HSB/HSV mode and hide the RGB mode.

Here follows an example that includes the workaround:

<asp:UpdatePanel ID="mainUpdatePanel" runat="server">
        <telerik:RadButton ID="RadButton1" runat="server" Text="RadButton"></telerik:RadButton>
        <asp:Panel runat="server" ID="wrappingPanel">
            <%--WORKAROUND PART 1 - add the RGBSLiders tab first--%>
            <telerik:RadColorPicker ID="RadColorPickerStart" runat="server" PaletteModes="RGBSliders, HSB"></telerik:RadColorPicker>
            <%--WORKAROUND PART 2
            The script is wrapped in a RadScriptBlock so it gets
            registered and executed after the partial postback. By default, it will not be parsed--%>
            <telerik:RadScriptBlock runat="server" ID="rsb1">
                    Sys.Application.add_load(function () {
                        //a panel is used here to make looking for the color pickers added in it easier
                        //you can replace getting the reference to the color picker with any preferred method
                        $telerik.$("[id$='wrappingPanel']").find(".RadColorPicker").each(function (index, elem) {
                            if (elem && elem.control) {
                                var picker = elem.control;
                                setTimeout(function () {
                                    //trigger the internal logic of the control that will switch the tabs
                                    //in this case - the HSB tab is "clicked"
                                    picker._tabClicked({ target: $telerik.$(picker._tabStrip).find("a[title='HSB']")[0] });
                                    //hide the RGB tab
                                }, 0);//the timeout is needed so the control can initialize before we manipulate it
Protected Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
    wrappingPanel.Visible = True
End Sub