Results 1 to 4 of 4

Thread: Color in my Combo box

  1. #1

    Default Color in my Combo box

    Hello,
    how can I put colored text in my combo box? I tried putting

    Code:
     Ext.data.dogs = [
     ['1', '<font color="red">Rover</font>'],
     ['2', '<font color="brown">Snoopy</font>']
    ];
    The words are colored when I do the dropdown, but once they fill in the top space, I see the whole html.

    Does anyone have a solution?

  2. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default

    here is my solution from the extthemes site (bottom toolbar).
    it is not exactly the same, but modifying the template a bit should work out fine.

    Code:
    new Ext.ux.TwinTriggerCombo({
                                             displayField    : 'name'
                                            ,forceSelection  : true
                                            ,id              : 'colorCombo'
                                            ,minChars        : 0
                                            ,mode            : 'local'
                                            ,selectOnFocus   : true
                                            ,trigger1Class   : 'x-form-clear-trigger'
                                            ,trigger2Class   : 'x-form-arrow-trigger'
                                            ,width           : 120
                                            ,onTrigger1Click : function(){
                                                this.clearValue();
                                                multiFilter();
                                            }
                                            ,store : new Ext.data.ArrayStore({
                                                 fields  : ['color' ,'name']
                                                ,idIndex : 0
                                            	,data    : [
                                                     ['0000ff' ,'Blue']
                                                    ,['c0c074' ,'Champagne']
                                                    ,['808080' ,'Gray']
                                                    ,['008000' ,'Green']
                                                    ,['ffffff' ,'Mixed']
                                                    ,['ffa500' ,'Orange']
                                                    ,['ff0000' ,'Red']
                                                    ,['ffff00' ,'Yellow']
                                                 ]
                                            })
                                            ,tpl : new Ext.XTemplate(
                                                '<tpl for="."><div class="x-combo-list-item">',
                                                    '<div class="colorDiv" style="background-color:#{color};"></div><span style="margin-left:22px;">{name}</span>',
                                                '</div></tpl>')
                                        })
    Best regards
    Tobias Uhlig

  3. #3

    Default

    Thanks. That's great, but I cannot have the color in my data. I need my value and display data to be just the word I am displaying. Is there another way? Is there a way like the way you can change the color in a grid using a function?

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Use a custom template in the combo. See the examples page and the API docs.

Similar Threads

  1. Combo box selected value color
    By bhaskar1605 in forum Ext 2.x: Help & Discussion
    Replies: 9
    Last Post: 25 Sep 2008, 11:56 PM
  2. Combo box selected value color
    By bhaskar1605 in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 25 Sep 2008, 6:31 AM
  3. Combo box selected value color
    By bhaskar1605 in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 25 Sep 2008, 6:00 AM
  4. Combo box selected value color
    By bhaskar1605 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 25 Sep 2008, 5:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •