[CLOSED] Change color in ComboBox, depending on values

  1. #1

    [CLOSED] Change color in ComboBox, depending on values

    Hi
    Ho do I change the color of each row in a combobox, depending on the combobox value.
    Value 1 - "V1" (Red)
    Value 2 - "V2" (Green)
    Value 3 - "V3" (Blue)

    Thanks!
    Last edited by Daniil; Feb 16, 2011 at 12:45 PM. Reason: [CLOSED]
  2. #2
    Hi Jurke,

    Please use Template.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!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>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:ComboBox runat="server">
            <Items>
                <ext:ListItem Text="Red" Value="0" />
                <ext:ListItem Text="Green" Value="1" />
                <ext:ListItem Text="Blue" Value="2" />
            </Items>
            <Template>
                <Html>
                    <tpl for=".">
                        <h1 style="color:{text}">{text}</h1>
                    </tpl>
                </Html>
            </Template>
        </ext:ComboBox>
        </form>
    </body>
    </html>
    See also
    https://examples1.ext.net/#/Form/Com...rop_Down_List/
  3. #3
    Thanks,
    This is exactly what I want to do, except that I dont want the Text property to contain the color name. Is this possible?

    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <!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>Ext.Net Example</title> 
    </head> 
    <body> 
        <form runat="server"> 
        <ext:ResourceManager runat="server" /> 
        <ext:ComboBox runat="server"> 
            <Items> 
                <ext:ListItem Text="Value 1" Value="0" /> //Red
                <ext:ListItem Text="Value 2" Value="1" /> //Green
                <ext:ListItem Text="Valye 3" Value="2" /> //Blue
            </Items> 
            <Template> 
                <Html> 
                    <tpl for="."> 
                        <h1 style="color:{???}">{text}</h1> 
                    </tpl> 
                </Html> 
            </Template> 
        </ext:ComboBox> 
        </form> 
    </body> 
    </html>
  4. #4
    Sure.

    Example
    <%@ Page Language="C#" %>
      
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
      
    <!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>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:ComboBox runat="server">
            <Items>
                <ext:ListItem Text="Value 1" Value="0" />
                <ext:ListItem Text="Value 2" Value="1" />
                <ext:ListItem Text="Value 3" Value="2" />
                <ext:ListItem Text="Default color (any value)" Value="3" />
            </Items>
            <Template>
                <Html>
                    <tpl for=".">                
                        <h1 style="color:{[values.value == 0 ? 'red' : values.value == 1 ? 'green' : values.value == 2 ? 'blue' : 'black']}">{text}</h1>
                    </tpl>
                </Html>
            </Template>
        </ext:ComboBox>
        </form>
    </body>
    </html>
    See also
    http://dev.sencha.com/deploy/dev/doc...mber=XTemplate
  5. #5
    Thanks!
    Excellent

Similar Threads

  1. Replies: 3
    Last Post: Feb 21, 2012, 6:40 AM
  2. change color
    By oseqat in forum 1.x Help
    Replies: 10
    Last Post: Aug 29, 2011, 5:44 PM
  3. Change Cell background depending on value
    By GijsZePa in forum 1.x Help
    Replies: 2
    Last Post: Apr 06, 2010, 3:58 AM
  4. [CLOSED] How to change ComboBox border color using CSS?
    By flormariafr in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Mar 05, 2010, 4:40 PM
  5. Replies: 12
    Last Post: Jun 17, 2009, 12:07 PM

Tags for this Thread

Posting Permissions