Results 1 to 3 of 3

Thread: ExtJs 3.3.0 - Colored dropdown list ComboBox depending on the text

  1. #1

    Default ExtJs 3.3.0 - Colored dropdown list ComboBox depending on the text

    Hello,

    I would like to change the background color of some records of my dropdown list of a combobox depending on its content

    example: I use a combobox to list some available country:
    Code:
    { 
      xtype:            'combo', 
      id:               'my-dynamic-combo', 
      fieldLabel:       'Select country', 
      mode:             'local', 
      valueField:       'country', 
      displayField:     'country', 
      typeAhead:        true, 
      forceSelection:   true, 
      triggerAction:    'all', 
      editable:         false, 
      allowBlank:       false, 
      store:        new Ext.data.XmlStore( 
      { 
        url:      '/cgi-bin/MyCGI.cgi', 
        record:   'country', 
        fields:   ['id', 'country'] 
      }) 
    }
    I would like to avoid the selection of the same country twice, so to do that I have 2 choices:
    1. inform the user that the listed country is already selected (by changing its background color on the list)
    example:
    Code:
    for (var i =  0 ; i < AssignedPeopleTable.length ; i ++) 
    { 
      for (var j =  0 ; j < Ext.getCmp('my-dynamic-combo').store.length ; j ++) 
      { 
        if (AssignedPeopleTable[i]['country'] == Ext.getCmp('my-dynamic-combo').store.data.items[j]['country'])
        {
          setBackgroundColor(RED);
          return;
        }
      }
    }

    or
    2. remove the mentioned country from the list (so remove it from the store)



    I guess the simplest way to do it is the first possibility...?

    Can you give some advice?

    Thank you very much

  2. #2
    Sencha User
    Join Date
    Jan 2011
    Posts
    549

    Default

    I would've actually thought removing all duplicate records from your store would be a much simpler solution?

  3. #3

    Default [RESOLVED]

    Quote Originally Posted by willigogs View Post
    I would've actually thought removing all duplicate records from your store would be a much simpler solution?
    Thank you for your answer.

    I didn't know it was that simple to parse my store and remove any item .
    Thanks again
    Last edited by follivier; 5 Mar 2014 at 3:05 AM. Reason: Mark as resolved

Posting Permissions

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