[CLOSED] Mozilla provblem

  1. #1

    [CLOSED] Mozilla provblem

    hi,

    i have set a cell background color gor gridpanel.The code is working fine in internet exploar and set the cell background color. And the problem is the code is working fine in mozilla browser but the cell background color is not set in gridpanel. i am using the rgb values for colors. please give a solution. urgent...


    
    
    
    
    
    
    
    <ext:Store ID="Store3" runat="server" >
    
    <Reader>
    
    <ext:ArrayReader> <Fields>
    
    <ext:RecordField Name="COLOUMN1" />
    
    <ext:RecordField Name="COLOUMN2" /> 
    
    </Fields>
    
    </ext:ArrayReader>
    
    </Reader>
    
    </ext:Store>
     
    
    <ext:GridPanel ID="GridPanel3" runat="server" StoreID="Store3" 
    
    Height="150px" Width="500px" MonitorResize="false">
    
    <ColumnModel ID="ColumnModel3" runat="server" >
    
    <Columns> 
    
    <ext:Column DataIndex="COLOUMN1" Header="Colour" >
    
    <Renderer Fn="COLOUMN1" />
    
    </ext:Column> 
    
    <ext:Column DataIndex="COLOUMN2" Header="Pantone No" /> 
    
    </Columns>
    
    </ColumnModel> 
    
    
    
    
    
    </ext:GridPanel>
    c# code:
    
    this.Store3.DataSource = new object[]
    
    {
    
    new object[] {"32,32,32",488},
    
    new object[] {"153,160,123",458}
    
    
    
    
    
    };
    
    
    this.Store1.DataBind();
    
    
    
    
    
    
    
    <script type="text/javascript">
    
    
    
    
    
    var template = '<div style="height:20px; margin:1px; padding:0px; width:100%; background-color:{0};">{1}
    ';
    
    
    
    
    
    
    
    var COLOUMN1 = function(value) 
    
    { 
    
    var where_is_mytool=value;
    
    var mytool_array=where_is_mytool.split(","); 
    
    return String.format(template,RGBtoHex(mytool_array[0],mytool_array[1],mytool_array[2]),value);
    
    } 
    
    
    
    function RGBtoHex(R,G,B)
    
    { 
    
    return toHex(R)+toHex(G)+toHex(B) 
    
    }
    
    
    
    function toHex(N)
    
    {
    
    if (N==null) return "00";
    
    N=parseInt(N); if (N==0 || isNaN(N)) return "00";
    
    N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
    
    return "0123456789ABCDEF".charAt((N-N%16)/16)+ "0123456789ABCDEF".charAt(N%16);
    
    }
    
    
    
    </script>
    </PRE>
  2. #2

    RE: [CLOSED] Mozilla provblem

    Hi speedstep,

    I wasn't able to quickly recreate the problem based on the code sample you provided, but maybe try adding a hash (#) character to the start of the hex colour.


    Example


    return '#' + toHex(R) + toHex(G) + toHex(B);

    Another thought... it might be better to do this RGB-to-Hex conversion on the server. If all you need is the Hex value, then do the processing on the server and just include the Hex value in the data. That should help with performance.*


    Hope this helps.


    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] Mozilla provblem

    Hi speedstep,

    I simplified your code sample into a single .aspx demonstrating how I would probably go about solving this problem. Personally I would do the Pantone-to-RGB-to-Hex conversions on the server. You might also want to send a "text" color for the cell, given black text is not going to render well on a dark hex color.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Store1.DataSource = new object[]
            {
                new object[] { "32,32,32", 488, "#202020", "#ffffff" },
                new object[] { "153,160,123", 458, "#99A07B", "#ffffff" }
            };
            
            this.Store1.DataBind();
        }
    </script>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>RGB to Hex GridPanel Cell Conversion - Coolite Toolkit Example</title>
        
        <script type="text/javascript">
            var setColor = function(value, meta, record) {
                var tpl = 'style="background-color:{0};color:{1};"';
                meta.attr = String.format(tpl, record.data['color'], record.data['textColor']);
                return value;
            }
    </script>
    </head>
    <body>
        <p><a href="RGBtoHex.aspx">Reload</a></p>
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:Store ID="Store1" runat="server" >
                <Reader>
                    <ext:ArrayReader> 
                        <Fields>
                            <ext:RecordField Name="RGB" />
                            <ext:RecordField Name="Pantone" /> 
                            <ext:RecordField Name="color" /> 
                            <ext:RecordField Name="textColor" /> 
                        </Fields>
                    </ext:ArrayReader>
                </Reader>
            </ext:Store>
             
            <ext:GridPanel 
                ID="GridPanel1" 
                runat="server" 
                StoreID="Store1" 
                Height="150px" 
                Width="500px">
                <ColumnModel runat="server" >
                    <Columns>
                        <ext:Column DataIndex="Pantone" Header="Pantone No">
                            <Renderer Fn="setColor" />
                        </ext:Column>
                    </Columns>
                </ColumnModel> 
            </ext:GridPanel>
        </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Founder

Similar Threads

  1. Mozilla Firefox 4.0.1 compatiability issue
    By NishaLijo in forum 1.x Help
    Replies: 0
    Last Post: Jun 03, 2011, 10:33 AM
  2. [CLOSED] Fieldset Problem Mozilla/IE9
    By sisa in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 06, 2011, 12:49 PM
  3. [CLOSED] KeyMap in Panel not working in mozilla
    By klavsm in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 17, 2010, 10:19 AM
  4. Compatibility view issue in IE 8 and Mozilla
    By Nagaraj K Hebbar in forum 1.x Help
    Replies: 12
    Last Post: Jan 14, 2010, 11:36 PM
  5. [CLOSED] Design issue in Mozilla
    By Etisbew in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 02, 2009, 6:00 AM

Posting Permissions