Colormenu - define custom color palette

  1. #1

    Colormenu - define custom color palette

    In version 2.x, how can I define a custom color palette for a ColorMenu item ?

    thanks in advance

    see example below
    <%@ Page Language="C#" %>
    
    
    <!DOCTYPE html>
    
    
    <html>
    <head runat="server">
        <title>Ext.NET Example</title>
        <link href="/resources/css/examples.css" rel="stylesheet" />
    
    
        <script>
    
    
            var setColor = function (menu, color) {
                var cmp;
    
    
                if (menu.lastTargetIn(App.Panel1)) {
                    cmp = App.Panel1;
                } else if (menu.lastTargetIn(App.Panel2)) {
                    cmp = App.Panel2;
                }
    
    
                cmp.body.applyStyles(Ext.String.format('background-color:#{0}', color));
            };
    
    
            var onDocReady = function () {
                if (Ext.isFirefox51)
                    document.body.addEventListener("contextmenu", function (e) { e.preventDefault(); }, false);
            }
    
    
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server">
                <Listeners>
                    <DocumentReady Handler="onDocReady();" />
                </Listeners>
            </ext:ResourceManager>
    
    
            <ext:ColorMenu ID="ColorMenu1" runat="server"> 
                <Picker runat="server" Value="FFFFFF"  />
                <Listeners>
                    <Select Handler="setColor(#{ColorMenu1}, color);" />
                </Listeners>
            </ext:ColorMenu>
    
    
            <ext:Panel
                ID="Panel1"
                runat="server"
                Height="200"
                Title="Right-Click on this Panel"
                ContextMenuID="ColorMenu1" />
    
    
            <ext:Panel
                ID="Panel2"
                runat="server"
                Height="200"
                Title="Right-Click on this Panel too!"
                ContextMenuID="ColorMenu1" />
        </form>
    </body>
    </html>
    Last edited by tanky65; Dec 12, 2018 at 8:04 AM.
  2. #2

    solution

    just use the Colors property of the Picker element, here in the example, using code behind

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                ColorMenu1.Picker.Colors = new string[] { "FFFFFF", "000000", "333333", "455432" };
            }
        }

Similar Threads

  1. [CLOSED] Legend color problem on pi3D chart with custom color
    By feanor91 in forum 4.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 17, 2017, 5:29 PM
  2. [CLOSED] Custom color in GridPanel
    By osef in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 12, 2014, 10:49 PM
  3. [CLOSED] how to custom define english tips
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 16, 2013, 1:29 AM
  4. Replies: 1
    Last Post: Dec 12, 2012, 3:21 PM
  5. [CLOSED] How to open Color Palette
    By egvt in forum 1.x Legacy Premium Help
    Replies: 10
    Last Post: May 14, 2012, 7:05 AM

Tags for this Thread

Posting Permissions