Sun 22 Jun 2008
Using ExtJS to render UI
Posted by Duvall Buck under ExtJS
No Comments
First off I need to state that learning to use ExtJS has been extremely difficult for me. The roadblocks are:
- I’ve made a career out of saying, “I don’t do no stinking UI”
- I don’t know HTML or CSS very well
- The tutorials, articles and APIs aren’t the best.
- I have no Intellisense for ExtJS
Some of these problems are my own but some of them are ExtJS too. I’ve decided to fix the problems that are mine by learning more about HTML and CSS. The problems with ExtJS resources are they are mainly of the introductory type. That is fine if all you want to do is use their ‘templates’. Of course I want to modify and change from the ‘templates’. This has taken me a lot of time with the ‘experiment and run’ iterations. The Intellisense issue is being addressed but the project is being attached to VS 2008 so if you’re using VS 2005 you’ll be out of luck.
Here is what I’ve now got:
This is similar to what I had using pure CSS/HTML but now it is being rendered using ExtJS. Here is the HTML:
1: <html>
2: <head>
3: <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
4: <link rel=”stylesheet” type=”text/css” href=”../../Content/extJS/resources/css/ext-all.css” />
5: <link rel=”stylesheet” type=”text/css” href=”../../Content/extJS/resources/css/genealogist.css” />
6: <script type=”text/javascript” src=”../../Content/extJS/adapter/ext/ext-base.js”></script>1:2: <script type=“text/javascript” src=“../../Content/extJS/ext-all-debug.js”>1: </script>2: <script type=“text/javascript” src=“../../Content/js/default.js”></script>
7:
8: <title>CrawBuck Genealogist</title>
9: </head>
10: <body>
11: <div id=”west”></div>
12: <div id=”north”>Genealogist</div>
13: <div id=”center2″></div>
14: <div id=”center1″></div>
15: <div id=”south”>Copyright 2008 CrawBuck</div>
16: </body>
17: </html>
Here is the default.js file:
1: Ext.BLANK_IMAGE_URL = ‘../../Content/images/s.gif’;
2: Ext.onReady(function() {
3:
4: var viewPort = new Ext.Viewport({
5: layout:‘border’,
6: items:[
7: new Ext.BoxComponent({ // raw
8: region:‘north’,
9: el: ‘north’,
10: height:100,
11: style:‘background-image:url(../Content/images/BannerBackground.png);background-repeat:repeat-x;border:solid 1px #1D6241;text-align:right;vertical-align:middle;padding-right:10px;font-family:Georgia;font-size:75px;color:#ED7014;’
12: }),
13: new Ext.BoxComponent({
14: region:’south’,
15: el: ’south’,
16: height:25,
17: style:‘background-image:url(../Content/images/FooterBackground.png);background-repeat:repeat-x;border:solid 1px #1D6241;text-align:center;font-family:Verdana;font-weight:bold;color:#ED7014;padding-top:5px;’
18: }),{
19: region:‘west’,
20: id:‘west-panel’,
21: title:‘West’,
22: split:true,
23: width: 200,
24: minSize: 175,
25: maxSize: 400,
26: collapsible: true,
27: margins:‘0 0 0 5′,
28: layout:‘accordion’,
29: layoutConfig:{
30: animate:true
31: },
32: items: [{
33: contentEl: ‘west’,
34: title:‘Navigation’,
35: border:false,
36: iconCls:‘nav’
37: },{
38: title:‘Settings’,
39: html:‘<p>Some settings in here.</p>’,
40: border:false,
41: iconCls:’settings’
42: }]
43: },
44: new Ext.TabPanel({
45: region:‘center’,
46: deferredRender:false,
47: activeTab:0,
48: items:[{
49: contentEl:‘center1′,
50: title: ‘Close Me’,
51: closable:true,
52: autoScroll:true
53: },{
54: contentEl:‘center2′,
55: title: ‘Center Panel’,
56: autoScroll:true
57: }]
58: }) // end of TabPanel
59: ] // end of items
60: });
61:
62: }); // eo function onReady
63:
64: // eof
This is modified from the Complex BorderLayout template. This template provides north, south, center, east and west regions. If you look at the HTML you will notice I have removed the east region. For the north region I have added the banner rendering and in the south region I have added the footer rendering. The west region will be an accordian panel and the center region will be a tab panel. The west and center will have to interact with one another.
I also want to create components that can be used to render the accordian and the center regions. ExtJS allows this but I’m again stuck learning this through ‘experiment and run’ iterations.
I will explain one of the problems I had in getting this to render. This is what I started with for the south region. The problem was that the height wasn’t taking and the south region was rendering much more than 25 pixels.
1: }),{
2: region:’south’,
3: el: ’south’,
4: height:25,
5: style:‘background-image:url(../Content/images/FooterBackground.png);background-repeat:repeat-x;border:solid 1px #1D6241;text-align:center;font-family:Verdana;font-weight:bold;color:#ED7014;padding-top:5px;’
6: },{
7: region:‘west’,
So I tried to put the footer inside a BoxComponent like this:
1: }),{ new Ext.BoxComponent({
2: region:’south’,
3: el: ’south’,
4: height:25,
5: style:‘background-image:url(../Content/images/FooterBackground.png);background-repeat:repeat-x;border:solid 1px #1D6241;text-align:center;font-family:Verdana;font-weight:bold;color:#ED7014;padding-top:5px;’
6: }),{
7: region:‘west’,
This won’t render and I didn’t know why. This is where Intellisense would have really helped. It turned out that I shouldn’t have the ‘}’ in the }),{ new Ext.BoxComponent. The correct syntax is this:
1: }),
2: new Ext.BoxComponent({
3: region:’south’,
4: el: ’south’,
5: height:25,
6: syle:‘background-image:url(../Content/images/FooterBackground.png);background-repeat:repeat-x;border:solid 1px #1D6241;text-align:center;font-family:Verdana;font-weight:bold;color:#ED7014;padding-top:5px;’
7: }),{
8: region:‘west’,
That only took me about 3 hours to figure out.