Telerik Forums
UI for ASP.NET AJAX Forum
0 answers
42 views

Hi,

Is there a way to choose BackgroundColor of cells in RadSpreadsheet from UI that are not part of the given list of colors???
or maybe a way to edit the background color # from UI ???

 

thanks,

Efrat

Efrat
Top achievements
Rank 1
 asked on 23 Mar 2023
1 answer
56 views

Hi,

In RadEditor I need to use radcolorpicker to add custom colors.  When we click "Add Custom Color" now its giving a popup and

we need to type the hex color code.

without doing that is there a way to use radcolorpicker after click the  "Add Custom Color".

 

Thank You,

Sahan

Rumen
Telerik team
 answered on 30 Mar 2022
1 answer
44 views

Hiya,

I have a grid with a template column that contains a RadColorPicker. I would like to read the color values in a postback.  However, using the code below, I'm only getting the values from the original data source.

ASPX:

<telerik:RadGrid ID="grdUser" runat="server" AllowMultiRowSelection="true" AutoGenerateColumns="false" ShowStatusBar="true"
            AllowSorting="True" AllowFilteringByColumn="true"
            OnItemDataBound="grdUser_ItemDataBound">
            <MasterTableView DataKeyNames="UserId, UserName, HexCode" CommandItemDisplay="None">
                <Columns>
                    <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="40px"/>

                    <telerik:GridBoundColumn UniqueName="UserName" HeaderText="Name" DataField="UserName" /> 

                    <telerik:GridTemplateColumn DataField="HexCode" HeaderText="Route Colour" UniqueName="HexCode">
                        <EditItemTemplate>
                            <telerik:RadColorPicker ID="editColor" runat="server" SelectedColor='<%# Bind("HexCode") %>' />
                        </EditItemTemplate>
                         <ItemTemplate> 
                             <telerik:RadColorPicker id="RadColorPicker1" runat="server" ShowIcon="true" /> 
                         </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <Selecting AllowRowSelect="true" />
                <Scrolling AllowScroll="True" UseStaticHeaders="True" />
            </ClientSettings>
        </telerik:RadGrid>

        <telerik:RadButton ID="btnGo" runat="server" Text="Go"  />

C#:

 protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add("UserId", typeof(long));
            dataTable.Columns.Add("UserName", typeof(string));
            dataTable.Columns.Add("HexCode", typeof(string));

            dataTable.Rows.Add(1, "Bob", "#2E8B57");
            dataTable.Rows.Add(2, "Tim", "#BA55D3");
            dataTable.Rows.Add(3, "Jim", "#FF8C00");
            dataTable.Rows.Add(4, "Rob", "#4682B4");
            dataTable.Rows.Add(5, "Dan", "#B22222");

            grdUser.DataSource = dataTable;
            grdUser.DataBind();
        }
        else
        {
            foreach (Telerik.Web.UI.GridDataItem user in grdUser.SelectedItems)
            {
                // Read new color values from the grid.
                string alteredColor = grdUser.MasterTableView.DataKeyValues[user.ItemIndex]["HexCode"].ToString();
            }
        }
    }

    protected void grdUser_ItemDataBound(object sender, GridItemEventArgs e)
    {
        GridDataItem item = e.Item as GridDataItem;

        if (item != null)
        {
            RadColorPicker rcpDeviceColour = e.Item.FindControl("RadColorPicker1") as RadColorPicker;

            if (rcpDeviceColour != null)
            {
                string hexCode = item.GetDataKeyValue("HexCode").ToString();
                rcpDeviceColour.SelectedColor = System.Drawing.ColorTranslator.FromHtml(hexCode);
            }
        }
    }

How do I read the updated color values in the grid during a postback?

Thanks in advance,

Matt

Matthew
Top achievements
Rank 1
Iron
Iron
 answered on 13 Dec 2021
4 answers
69 views

Hello,

I'm trying to localize the RadColorPicker using resource-files placed in the App_GlobalResources of my website, which is working fine for most of the telerik controls (e.g. RadComboBox). In case of the RadColorPicker, adding these resource files doesn't seem change anything. For example the following code does not use any resource-file values for the texts and tooltips of "No color", "Custom color" as well as the "OK" and "cancel" buttons within the "Custom color" sub-control.

<telerik:RadColorPicker runat="server" ID="RadColorPickerStatusColor" Preset="Standard" EnableCustomColor="true" SelectedColor="#FFFFFF" />

 

Because I'm using this control in multiple places, I dislike the way localization for RadColorPicker is beeing described in the docs (Telerik Docs: RadColorPicker). Additionally, I'm not able to find the key for at least the cancel-button within the supplied resource files (en, de, fr; which are available for download at https://www.telerik.com/account/product-download?product=RCAJAX).

As for the screenshot, the current Culture of the website is German, so I would expect the RadColorPicker to be displayed using the RadColorPicker.de-DE.resx file. Obviously these values are English though.

 

Any tips on the missing key for the cancel-button or the fact, that there's no localization at all?

Kind regards

Peter Milchev
Telerik team
 answered on 12 Jun 2020
7 answers
650 views

Issue 1:

I'm trying to add a radcolorpicker to a grid such that when inserting or updating a row, the color picker will display and it's selected value will show in the "Color" column field.

Using a templates i've added it to the edit column, but it doesn't do anything, can't even select colors, and when compiled and ran I get a javascript error: "Sys" is undefined.

I'm sure I have the basic idea of how to use it wrong.  Of course. :)

I have a scriptmanager in place, although I'm not going to speculate on what that does. :)

Any ideas on what I'm missing, or doing wrong?

Issue 2:

protected void RadColorPicker1_ColorChanged(object sender, EventArgs e)  
{  
   Label1.Text = ColorTranslator.ToHtml(RadColorPicker1.SelectedColor);  

When compiling this gives me a compile time Error -- 
"The name 'RadColorPicker1' does not exist in the current context ..."

How do I ensure it's context?

Al

<radG:RadGrid   
    ID="RadGrid2" runat="server" 
    Height="100px" 
    Width="500px" 
    Title="Rules" 
    BorderStyle="Solid"   
    BorderWidth="1px" 
    DataSourceID="ObjectDataSource1"   
    GridLines="None" 
    AllowAutomaticInserts="True" 
    AllowAutomaticUpdates="True" 
    AutoGenerateColumns="False" 
    MasterTableView-AllowPaging="true" 
    OnDeleteCommand="RadGrid2_DeleteCommand"   
    OnPreRender="RadGrid2_PreRender"   
    OnItemEvent="RadGrid2_ItemEvent"   
    OnItemInserted="RadGrid2_ItemInserted"   
    OnItemUpdated="RadGrid2_ItemUpdated"   
    OnCancelCommand="RadGrid2_CancelCommand"   
    OnDataBound="RadGrid2_DataBound" > 
    <MasterTableView  
        DataKeyNames="idExceptionRule"   
        DataSourceID="ObjectDataSource1" 
        AllowPaging="True" > 
        <ExpandCollapseColumn Visible="False">  
            <HeaderStyle Width="19px" /> 
        </ExpandCollapseColumn> 
        <RowIndicatorColumn Visible="False">  
            <HeaderStyle Width="20px" /> 
        </RowIndicatorColumn> 
        <Columns> 
            <radG:GridBoundColumn DataField="decMin" HeaderText="From" UniqueName="From">  
            </radG:GridBoundColumn> 
            <radG:GridBoundColumn DataField="decMax" HeaderText="To" UniqueName="To">  
            </radG:GridBoundColumn> 
            <radG:GridBoundColumn DataField="hexColourFont" HeaderText="Color" UniqueName="Color">  
                <ItemStyle BackColor="White" BorderColor="#404040" BorderStyle="Solid" BorderWidth="1px" 
                    HorizontalAlign="Left" VerticalAlign="Middle" /> 
            </radG:GridBoundColumn> 
            <radG:GridTemplateColumn DataField="hexColourFont" ShowSortIcon="False" UniqueName="TemplateColumn">  
                <EditItemTemplate> 
                   <telerik:RadColorPicker ID="RadColorPicker1" runat="server" Preset="Web216" 
                        ShowIcon="True" OnDataBinding="RadColorPicker1_ColorChanged" AutoPostBack="True" OnColorChanged="RadColorPicker1_ColorChanged">  
                    </telerik:RadColorPicker> 
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
                </EditItemTemplate> 
            </radG:GridTemplateColumn> 
            <radG:GridEditCommandColumn> 
            </radG:GridEditCommandColumn> 
            <radg:GridButtonColumn CommandName="Delete" Text="Delete" 
               UniqueName"DeleteColumn" ButtonType="ImageButton" ImageUrl=".\delete.gif" /> 
 
        </Columns> 
        <EditFormSettings> 
            <EditColumn UniqueName="EditCommandColumn1">  
            </EditColumn> 
        </EditFormSettings> 
    </MasterTableView> 
    <ValidationSettings CommandsToValidate="PerformInsert,Update,Delete" /> 
</radG:RadGrid>    
Attila Antal
Telerik team
 answered on 10 Jun 2020
1 answer
63 views
When I use RadColorPicker, select color and click on Apply button I get my page refreshed and I lost selected color. How this can be fixed. Is this some RadColorPicker functionality.

Rumen
Telerik team
 answered on 10 Jun 2020
1 answer
44 views

When the color picker is on a tab that is not active when the page loads the cursor (crosshair) is not in the right location.  The color is correct, the cursor is not.  I tried a few things I saw in this forum, repainting clientside when the tab becomes active, and adding this script to the bottom of the page.  But no luck.  Any Ideas?  Thank you.  Telerik version = 2017.3.913.45

function OnClientActiveTabChanged()
{
    $find("<%=colorBackGround.ClientID %>").repaint();
}
Telerik.Web.UI.RadColorPicker.prototype._updateHslSliderBackground = function (hsl, isCustomColor)
        {
            var color = this._hslToRgb(hsl.h, hsl.s, 0.5);
            var slider = isCustomColor ? this.get_millionCustomColorsSlider() : this.get_millionColorsSlider();
            if (slider._trackElement)
            {
                slider._trackElement.style.backgroundColor = this._rgbValuesToHex(color.r, color.g, color.b);
            }
        }

 

Vessy
Telerik team
 answered on 18 May 2020
8 answers
355 views
Hi.

I have a project thats contain RadColorPicker. I need to change text color according the chosen one. inspect shows me the wrong color. Process steps;

     1)Choose color and close the RadColorPicker,

     2)Inspect still shows me the previous color that i chosen,

     3)Inspect has been updated when i clicked second time to RadColorPicker.

I don't know why is happening and need your help.

Thanks a lot.
Caner
Top achievements
Rank 1
 answered on 27 Dec 2018
1 answer
57 views
I need to set the focus to the Color Picker control from the user-defined jquery function.

Kindly Help, Thankx in Advance.
Marin Bratanov
Telerik team
 answered on 18 Jun 2018
1 answer
218 views

I want to set the color of color picker when the Page Load. But it always cannot find the rad color picker control. It always get null.

protected void Page_Load(object sender, EventArgs e)
{
    if (IsPostBack == false)
    {               
        string szJS = "OptionSettingsLoad();";
        RadScriptManager.RegisterStartupScript(this, this.GetType(), "OptionSettingsLoad", szJS, true);
    }
}

 

The javascript has add the global function for initialize the TelerikDemo object and its function for color change.

I cannot find the color picker control by

var colorPickerDischargeTitleColor = $find("RadColorPickerDischargeTitleColor");

the color Picker"colorPickerDischargeTitleColor " always be null.

 

function (global, undefined) {
 
    var TelerikDemo = global.TelerikDemo = {};
 
    function OnClientColorChangeDischargeTitleColor(sender, eventArgs) {
 
        var colorPicker = $find("RadColorPickerDischargeTitleColor");
        var strColor = sender.get_selectedColor();
    }
 
    TelerikDemo.OnClientColorChangeDischargeTitleColor = OnClientColorChangeDischargeTitleColor;
 
    function OnClientColorChangeDischargeContentColor(sender, eventArgs) {
 
        //alert("Selected color is changed from " + eventArgs.get_oldColor() + " to " + sender.get_selectedColor() + ".");
        var colorPicker = $find("RadColorPickerDischargeContentColor");
        var strColor = sender.get_selectedColor();
    }
 
    TelerikDemo.OnClientColorChangeDischargeContentColor = OnClientColorChangeDischargeContentColor;
 
 
})(window);
 
 
function OptionSettingsLoad()
{
    var LS_titleColor = localStorage.getItem(DISCHARGE_TITLE_COLOR);
    var LS_contentColor = localStorage.getItem(DISCHARGE_CONTENT_COLOR);
 
    var colorPickerDischargeTitleColor = $find("RadColorPickerDischargeTitleColor");
    var colorPickerDischageContentColor = $find("RadColorPickerDischargeConetnteColor");
 
    //alert("LS_titleColor=" + LS_titleColor);
   
    HiddenDischargeTitleColor.value = LS_titleColor;
 
    if (colorPickerDischargeTitleColor != null && LS_titleColor != null)
    {      
        colorPickerDischargeTitleColor.set_selectedColor(LS_titleColor);
    }
 
    HiddenDischargeContentColor.value = LS_contentColor;
 
    if (colorPickerDischageContentColor != null && LS_contentColor != null)
    {
        colorPickerDischageContentColor.set_selectedColor(LS_contentColor);
    }
}

 

My RadColorPciker control in aspx as below:

<telerik:RadColorPicker ID="RadColorPickerDischargeTitleColor" runat="server" PaletteModes="HSB" ShowIcon="true" OnClientColorChange="TelerikDemo.OnClientColorChangeDischargeTitleColor" ></telerik:RadColorPicker>
 
<telerik:RadColorPicker ID="RadColorPickerDischargeContentColor" runat="server" PaletteModes="HSB" ShowIcon="true" OnClientColorChange="TelerikDemo.OnClientColorChangeDischargeContentColor" ></telerik:RadColorPicker>

 

Do I lose something to define or how to solve this problem?

章民
Top achievements
Rank 1
 answered on 02 Aug 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
horváth
Top achievements
Rank 2
Iron
Iron
Steve
Top achievements
Rank 2
Iron
Erkki
Top achievements
Rank 1
Iron
Mark
Top achievements
Rank 2
Iron
Iron
Veteran
Jakub
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?