Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: How setting backgroundColor in TextField (GXT)

  1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    15

    Question How setting backgroundColor in TextField (GXT)

    Hi guys!!!

    I'm trying to set the background color of a TextField (GXT) component but I only see changing the color of its borders, the background remains white

    I made the same for a Text component (GWT) and it works fine...so I'm on the horns of a dilemma

    Code:
     TextField<String> myTextField= new TextField<String>();  
    	    myTextField.setFieldLabel("myLabel");
                myTextField.setStyleName("textInputFocus");
    My CSS:

    HTML Code:
    .textInputFocus {
    	
    	background-color: green !important;
    	
    }
    Any hint?

    Thanks a lot!
    Bye, Luca

  2. #2
    Sencha Premium User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    888

    Default

    Hi.
    Try it like this (untested):
    PHP Code:
    myTextField.setStyleAttribute("backgroundColor""green"); 

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    15

    Default

    I've tried but always with the same result...only the TextField borders change color, not the background

    I've also tried

    Code:
     myTextField.setStylePrimaryName("textInputFocus");
     myTextField.addStyleName("textInputFocus");
    ... but nothing

  4. #4
    Sencha Premium User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    888

    Default

    You may try to get the InputEl via getInputEl (by using jsni or extending the class), and then setting the style there.
    If this also don't work, try with firebug, and find out what is the place to set the property.

    Regards,
    Michel.

  5. #5
    Sencha User
    Join Date
    Feb 2011
    Posts
    15

    Default

    Could you please give me a clue about getting the InputEl via getInputEl by using jsni ?

    Thanks a lot

  6. #6
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188

    Default

    There's a background image set on GXT TextFields which you have to remove.

  7. #7
    Sencha User
    Join Date
    Feb 2011
    Posts
    15

    Default

    Could you please suggest to me how removing this background image?
    I've tried:
    Code:
    myTextField.setStyleAttribute("backgroungImage", "");
    ...but with no success

  8. #8
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188

    Default

    myTextField.getInputEl().setStyleAttribute("backgroung-image", "none");

  9. #9
    Sencha User
    Join Date
    Feb 2011
    Posts
    15

    Default

    I've this error message:
    The method getInputEl() from the type TextField<String> is not visible

  10. #10
    Ext GWT Premium Member takayser's Avatar
    Join Date
    Oct 2008
    Location
    Lucerne, Switzerland
    Posts
    188

    Default

    use jsni if something is not visible:

    Code:
    @Jsni
    private native El getInputEl(Field<?> field)
    /*-{
       return [email protected]::getInputEl()();
    }-*/;
    or extend TextField and make it visible.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 2
    Last Post: 4 Mar 2009, 7:01 AM
  2. Setting TextField color - possible Bug
    By jfisher in forum Ext GWT: Help & Discussion (1.x)
    Replies: 1
    Last Post: 30 Sep 2008, 2:19 AM
  3. globally setting blankText in TextField
    By paulwang727 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 23 Sep 2008, 8:13 AM
  4. setting a textfield value
    By magicfrog in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 14 Jun 2008, 2:57 PM
  5. Setting value to textfield from JSON......
    By ajax&me in forum Ext 2.x: Help & Discussion
    Replies: 24
    Last Post: 22 Jan 2008, 5:43 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
  •