Home arrow JavaScript arrow Page 3 - EXT JS Passing Live Data
JAVASCRIPT

EXT JS Passing Live Data


Welcome to part two of the EXT-JS live data tutorial. In part one we created the underlying page and added the code to create the JsonStore, ColumnModel and GridPanel. Our GridPanel, however, currently has no data, so the first thing we’re going to do in this part of the tutorial is add the PHP code that will pass this data back to the JsonStore.

Author Info:
By: Dan Wellman
Rating: 3 stars3 stars3 stars3 stars3 stars / 3
July 27, 2009
TABLE OF CONTENTS:
  1. · EXT JS Passing Live Data
  2. · MySQL
  3. · Adding Additional Configuration Properties
  4. · Working More Closely with the Back End

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
EXT JS Passing Live Data - Adding Additional Configuration Properties
(Page 3 of 4 )

If you mouse over one of the grid headings you’ll see a drop-down appear. In the menu that opens when a drop-down is clicked, there is the option to show or hide any column, but the sortable options are grayed out. Enabling these is very easy and can be achieved with just one line of code. In gridExample.html add the following line of code directly after the ColumnModel code:


//allow column sorting

cm.defaultSortable = true;


This property causes all columns in the grid to be sortable. If we don’t want all of the columns to be sortable, we can enable sorting on selected columns by setting the sortable property to true on individual columns. Now when you run the page, you should be able to sort any column in either ascending or descending order:



There are a huge range of configurable properties that the ColumnModel can make use of in order to control the behavior of the columns. By default the columns are all resizable; to switch off this feature we can set the resizable property to false on each existing column definition:


//define the columns

var cm = new Ext.grid.ColumnModel([{

header:"Title",

dataIndex:"title",

width:170,

resizable:false

},{

header:"Image",

dataIndex:"image",

width:170,

resizable:false

},{

header:"In-Stock?",

dataIndex:"inStock",

width:70,

resizable:false

},{

header:"Price",

dataIndex:"price",

width:70,

resizable:false

},{

header:"Category",

dataIndex:"category",

width:70,

resizable:false

},{

header:"Manufacturer",

dataIndex:"manufacturer",

width:129,

resizable:false

}]);


Note that we can’t set all columns to resizable:false in the same way that we could configure all columns to be sortable. The only other general property like this is defaultWidth which will set the width of all columns.

As well as the properties we have used in this example, we can also make columns editable, hide individual columns, prevent columns from being hidden, set the alignment of the data, set CSS for column cells, disable the drop-down menu and specify tooltips for the column header, among other things.

There are also a whole range of properties that can be set on the GridPanel as well. For example, we can enable the addition of a load mask, which automatically adds a gray overlay and loading icon to the whole grid while the data is being retrieved. This can be enabled with the loadMask property, which should be added to the existing configuration object:


var grid = new Ext.grid.GridPanel({

el:"productGrid",

width:700,

height:500,

title:"Products",

store:dataStore,

cm:cm,

loadMask:true,

});


The load mask will probably only be visible to you for a second or so when testing locally, but your visitors will be reassured that something is happening behind the scenes while they wait for the data to be loaded, as this is likely to take longer in a live scenario.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- More Top jQuery Tutorials for Beginners
- More Top jQuery Plugins for Menus
- Top jQuery Tutorials for Beginners
- New UI Framework and SDK for JavaScript Rele...
- JavaScript OpenPGP Tool, Node.js 0.6.3 Avail...
- Yahoo Releases Cocktails Language and Develo...
- Customizing jQuery Slideshows: Dynamic Contr...
- Customizing jQuery Slideshows: the animate()...
- Customizing jQuery Slideshows: slideUp() and...
- Customizing jQuery Slideshows: hide() and sh...
- Web Workers: Performing Calculations in Para...
- More Top JavaScript Frameworks and Libraries
- More Dynamic jQuery Styling Techniques
- The Top JavaScript Libraries
- The Top JavaScript Frameworks

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials