My First ExtJS DataGrid Pt 2: Setting Up

So, off we go. First things first, you'll need the JQuery and ExtJS libraries. I also found out (the hard way, since it's not in the install notes) that you'll need the Dimensions JQuery Plugin. The full ExtJS download contains the project core files, JS library 'adapter' files, all of the Ext components, examples, documentation, and a 'resource' directory of images and stylesheets to help you get started.

I start off by placing the necessary script tags in the header of my document. Order of placement is important.

view plain print about
1<script type="text/javascript" src="js/jquery/jquery.js"></script>
2<script type="text/javascript" src="js/jquery/plugins/dimensions.js"></script>
3<script type="text/javascript" src="js/ext-1.0/adapter/jquery/ext-jquery-adapter.js"></script>
4<script type="text/javascript" src="js/ext-1.0/ext-all.js"></script>
5<script type="text/javascript" src="js/paging.js"></script>
6<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />

Now, for reference, you don't need the 'all' ext library for this to work, but I'm just doing personal testing right now and figured that it's easier than breaking things out at this point. The 'all' library is the complete component collection, core, and utilities within one script file. While nice to have it all, it is large, and you can use just the components you need. The 'Build your own Ext' section of the ExtJS site can show you all of the necessary dependencies to put together only what you need.

I'm going to copy the paging.js file out of the ExtJS example directory and place it in the root of my js directory. I'm going to adjust this existing file to create my first paging grid. I know that this works, so I might as well not re-write the wheel. You'll also noticed that I used the included stylesheet file from the resources directory. Now, with all of this in place, all I need is my container div that will hold my DataGride. In the body of my document I place the following container code:

view plain print about
1<div id="topic-grid" style="border:1px solid #99bbe8;overflow: hidden; width: 665px; height: 300px;"></div>

And that's the end of the initial setup. In part 3 I'll cover creating a paging sql page that will only call the records needed for each 'view' in our paging grid, returning the records in an XML format to be consumed by our grid. Until then, take a good look at the 'examples' directory in your ExtJS download, as well as the API and Examples section of Learn area of the ExtJS site. Also, included in the download below you will find the complete document we created today.

My First ExtJS DataGrid Pt 1

I can write my own code. I can take a process, define a proper algorithm for addressing an issue, and tap it out. In fact I enjoy the art of writing code, it's kinda like working on puzzles day in and day out, and I like a good puzzle. On the other hand I think it's also smart not to re-invent the wheel. Many minds have dealt with the same problems that I encounter every day, and someone has probably found a solution by now. Why fight that?

[More]