1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    42
    Vote Rating
    0
    obender is on a distinguished road

      0  

    Default How to set the Theme in onModuleLoad?

    How to set the Theme in onModuleLoad?


    I'm wondering what is the right way to set the Theme (let say Theme.GRAY) on load of a module. Basically I want my application to use a GRAY theme by default.
    It doesn't look like I can just do this:
    Code:
    public void onModuleLoad()
    {
            GXT.switchTheme( Theme.GRAY );
    ...
    }

  2. #2
    Ext User
    Join Date
    Apr 2008
    Posts
    42
    Vote Rating
    0
    obender is on a distinguished road

      0  

    Default


    is this going to be a Ok solution?
    Code:
    public void onModuleLoad()
        {
            //set theme
            if( StateManager.getProvider() == null ) {
                StateManager.setProvider( new CookieProvider( null, null, null, false ) );
            }
            StateManager.set( "theme", Theme.GRAY.asMap() );
            //--------------------
    ...
    }

  3. #3
    Sencha - GXT Dev Team darrellmeyer's Avatar
    Join Date
    May 2007
    Location
    Washington, DC
    Posts
    2,242
    Vote Rating
    2
    darrellmeyer is on a distinguished road

      0  

    Default


    Try this:

    Code:
    GXT.setDefaultTheme(Theme.GRAY, true);

  4. #4
    Ext User
    Join Date
    Apr 2008
    Posts
    42
    Vote Rating
    0
    obender is on a distinguished road

      0  

    Default


    Thanks!

  5. #5
    Ext User
    Join Date
    Jun 2009
    Posts
    3
    Vote Rating
    0
    mgrouse is on a distinguished road

      0  

    Default Preferences Panel and GXT.setTheme

    Preferences Panel and GXT.setTheme


    Hello:

    I have a slightly different problem. First the short version of my question. Is there any way I can call GXT.setTheme() (or some equivalent piece of code) in the 'middle' of my app (two frames open) and accomplish a theme change with OUT having the entire app reload?

    Now the long version:
    The reload is playing havoc with a static member of a static class that I have as essentially a singleton available to all panels opened by the user. The singleton holds info on the user (names etc.) and is loaded from the DB during onModuleLoad(). When I use GXT.setTheme() after save is pressed on a user prefs panel, the module reloads, which Would be ok, but this singleton does not reload with the recently saved info from the DB, but rather reverts to the version that existed when the user first opened the browser. Its as if some wierd caching is going on.

  6. #6
    Sencha User
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You can write your own "themechanger" that just toogles the css files without any reload.

  7. #7
    Ext User
    Join Date
    Jun 2009
    Posts
    3
    Vote Rating
    0
    mgrouse is on a distinguished road

      0  

    Default


    Quote Originally Posted by sven View Post
    You can write your own "themechanger" that just toogles the css files without any reload.
    Hmmm. I'm rather new to CSS and and all that. I've been using GWT and GXT for about 3 months now. I'm not entirely sure about what you are suggesting.

    Do you mean editing the DOM via code? Or are you refering to writing my own switchTheme() out of pieces from ThemeManager etc..

    Thanks for the fast reply!

  8. #8