I noticed that extjs comes with 3 to 4 default themes/skins . How can I select or swtich between the themes?
I want to change the blue to select the grey themes or something else.
Thanks
Ext.util.CSS.swapStyleSheet function can be used to switch between the different themes, this forums post shows an example.
Also I implemented this at first in my app a while back, but I ultimately found that forcing a browser refresh was necessary instead of dynamically swapping the CSS as there would still be some weird sizing/positioning issues. This was mainly when switching between the accessibility theme.
Though Ext.util.CSS.swapStyleSheet will work, It has few drawbacks:
1. It takes more time to render the page with new CSS theme.
2. While switching between themes, your page will be out of any css for a while. That will make the page look bad (broken and plain).
3. Unnecessary scrollbars will appear on the screen.
I overcame these using JavaScript:
Here,
Include all the CSS files in your HTML file.
<link rel="stylesheet" id="theme1" type="text/css" href="../Theme1.css" />
<link rel="stylesheet" id="theme2" type="text/css" href="../Theme2.css" />
Disable all the themes except one you want as default.
document.getElementById('theme1').disabled = true;
document.getElementById('theme2').disabled = false;
Now the page will be loaded with 'theme2'.
If you want to switch the theme. Do the opposite of the above...
document.getElementById('theme1').disabled = false;
document.getElementById('theme2').disabled = true;
In this way, the switching will be real fast. Since we have loaded all the css files initially. It will not ask the server for new theme every time.
It worked very well for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With