Ext

Archive for September, 2008

Ext GWT Grid Performance Improvements

Monday, September 29th, 2008

The Ext GWT Grid component, which was introduced in 1.1, plays an important role in most applications. Because of this, it is important for Grid to perform as fast as possible, especially when rendering large amounts of data. For the upcoming 1.1.1 release we took a fine grained look at the code to identify any performance bottlenecks. Code was tested and analyzed in host mode as well as all supported browsers. After this research, a couple of key changes to the code resulted in much faster rendering times. The new code was so much faster that I thought it would be nice to share the results.

A new test page was setup to allow both the old code and new code to be executed and timed. The tests were conducted on 3 different machines, with multiple browsers. For each test, rendering times where measured for 200 and 400 row grids. Here are the results of the tests:

Browser 200 Old 200 New Change 400 Old 400 New Change
Dual Xeon 3.16GZ , 8GB Mem
Host Mode IE 344 ms 362 ms 95% 1562 ms 719 ms 217%
IE7 3200 ms 1470 ms 218% 20064 ms 2906 ms 690%
FF2 2469 ms 469 ms 526% 7218 ms 843 ms 856%
FF3 711 ms 264 ms 269% 3368 ms 585 ms 576%
Safari Windows 860 ms 172 ms 500% 2594 ms 344 ms 754%
Mac Duo Core 2.5GZ, 2GB Mem
Safari 1343 ms 287 ms 468% 3719 ms 565 ms 658%
FF3 1276 ms 419 ms 305% 3056 ms 818 ms 374%
Intel Duo Core 2.4GZ, 3.5GB Mem
IE7 12716 ms 1855 ms 685% 37171 ms 3691 ms 1007%
FF2 5174 ms 828 ms 625% 18274 ms 1805 ms 1012%
Safari 1787 ms 327 ms 546% 5293 ms 654 ms 809%

As you can see, rendering times have been significantly reduced. You can run the test page yourself to see the improvements first hand.

The new grid code is available to SVN users, and will be included in our next release.

Improving Application Usability with Ext JS Keyboard Handling

Tuesday, September 23rd, 2008

As Enterprise applications begin moving to the web instead of the desktop many developers may forget about providing key bindings for their applications. Most web applications use the keyboard only for text entry and do not associate particular key combinations with user actions. By providing this type of key handling, particularly for applications which require a lot of data entry, we can improve the end-user experience.

While at a recent client engagement, we wanted to provide a smooth transition for users skilled at working with a legacy ‘green screen’ application to using a new Ext JS version. Part of this transition involved enabling power users to continue navigate the application with the same key handling. By the end-users not having to remove their hands from the keyboard, their efficiency increases substantially. Here’s some insight into how we accomplished the task at hand.

Ext.KeyMap

Ext provides several components that support keyboard navigation out of the box such as GridPanel, ComboBox, and TreePanel. To implement custom keyboard handling, developers can use the Ext.KeyMap and Ext.KeyNav classes to attach keyboard bindings to any component or element they wish.

The first set of keys we wanted to handle was all of the Function keys (F1-12). While most browsers reserve some/all of these keys, with some ext-pertise, we are able to override the default function if need be for our application. The application we were working with was completely dynamic and server driven, so we really couldn’t define all of the handlers ahead of time. This led to us dynamically building an array of key handler configuration objects and passing them all through to our new Ext.KeyMap object.

var keys = [];
for(var i = 0;i < buttons.length;i++) {
    var btn = buttons[i];
    // fkey property contains a string referencing the Ext constants (ie: Ext.EventObject.F1)
    var fk = eval(button.fkey);
    btn.handler = this.handleKey.createDelegate(this, [fk]);
 
    keys.push({
        key: fk,
        handler: this.handleKey.createDelegate(this, [fk]),
        stopEvent: true,
        scope: this
    });
}

This implementation demonstrates creating a toolbar and assigning function keys that would perform the same action when the button was clicked or when using the mouse. buttons is an array of button configurations that we pulled from the Json response from the server. The server is sending over a string which references some constants built into the Ext.EventObject for function keys. Since the data comes over as a string we can simply eval it and get the resulting number.

We use a generic handler for all of the click and keypress functions since it is all controlled from the server. createDelegate lets us pass along the key that was pressed so that we can share the same handler function regardless of if the event was a click or a keypress. With the keys array built and our handlers added into the buttons array, we are able to toss these into our Panel configuration and it will do the heavy lifting for us.

tabPanel.add({
    title: 'Test Panel',
    tbar: buttons,
    keys: keys
    ...
});

With our layout in place, adding a tab with our key handlers is pretty simple. The tbar parameter takes our array of Ext.Button configs that were server generated (aside from the handler), and the keys parameter takes an array to pass along to the Ext.KeyMap object.

Ext.KeyNav

The next set of key handling added was some additions to the grid keyboard navigation. The GridPanel has built in key navigation from the RowSelectionModel that it creates. Check out this grid example and select a row, you can then use the arrow keys to move up/down and even hold shift and press down to select a range of rows. We added a simple way to navigate through a large paged data set by extending GridPanel. The PagingToolbar provides keyboard handling once you’ve focused within the built-in TextField, but we wanted to allow the users to just hit ‘page down’ or ‘end’ when focus was anywhere within the GridPanel and ensure it functions as expected.

MyGrid = Ext.extend(Ext.grid.GridPanel,{
...
afterRender : function() {
   MyGrid.superclass.afterRender.call(this);
 
    this.nav = new Ext.KeyNav(this.getEl(),{
        pageDown: this.pagingNav.createDelegate(this,['next']),
        pageUp: this.pagingNav.createDelegate(this, ['prev']),
        home: this.pagingNav.createDelegate(this,['first']),
        end: this.pagingNav.createDelegate(this,['last']),
        scope: this
    });
},
 
pagingNav: function(page) {
    var pt = this.getBottomToolbar();
    if (!pt[page].disabled) {
        pt.onClick(page);
    }
},
...
});

This is a snippet from an extended GridPanel class, and it assumes that there is an Ext.PagingToolbar in place and it is the bottom toolbar (bbar). We could certainly write this code without the PagingToolbar, but it has already done the work to calculate page sizes and has handlers in place for determining the proper load call when skipping backwards/forwards in pages. We create our new Ext.KeyNav object and apply it to the GridPanel’s underlying Ext.Element. KeyNav does the work of assigning handlers to the proper key codes and calls our pagingNav function with the parameter that we bound to it using createDelegate. The pagingNav function merely checks to see if that particular button is disabled, for instance if you’re on the last page, you cannot press the next button again, so we don’t let them “page down” again either. As long as that button is not disabled we act as if the user clicked on the page next button and let the PagingToolbar do it’s magic and load the proper page.

Utilizing these techniques we were able to provide a seamless keyboard navigation experience for our client and their customers migrating from the legacy application to the web application

Getting Started

As you can see, adding custom key handling within an Ext JS application is quite easy. For any custom keys, including function keys, alpha keys with or without modifiers (alt/shift/ctrl) there is Ext.KeyMap. For navigation, arrows, paging, home/end there is Ext.KeyNav. There’s some more handy example code available for each right within the API documentation if you need any further help getting started.

Ext GWT 1.1 Released

Thursday, September 18th, 2008

We are pleased to announce the release of Ext GWT 1.1. This release is packed full of new features and components. Ext GWT 1.1 is a recommended upgrade for all Ext GWT 1.0 users.

New Features

Although a minor release, Ext GWT introduces many exciting new features to help build your rich internet application. With this release, Ext GWT shortens the feature set gap between Ext JS.

Grid

Grid
Ext 1.1 introduces the Grid component which includes the same feature set as the Ext JS Grid. Grids include an improved rendering model for improved rendering times.

Grid Plugins

Grid Plugins
Ext GWT 1.1 adds support for component plugins with the new ComponentPlugin interface which are objects that can “plug” into a component’s lifecycle. With Grid, plugins are used to modify the behavior of Grid to add new features. Included in this release are plugins for expanding rows, numbered rows, and check box rows.

Grid Grouping & Totaling

Grid Grouping & Totaling
The new Grid supports both grouping and totaling. Grouping is implemented by using the new GroupingStore which adds the ability to group the store’s data. The new Live Summary example demonstrates an editable grid with dynamic summary calculations.

EditableGrid

Editable Grid
EditableGrid is a Grid subtype that provides inline editing support using cell editors. Each editor wraps a Field subclass and provides editors based on the data type being edited. A nice feature of Grid is dirty cell marking. A cell shows a visual indicator when it is dirty as defined by the bound Store and Record. All changes to the Grid can be rejected or committed via the Store with the UI updating automatically.

ComboBox Additions

ComboBox
Auto complete and auto fill behavior has been added to ComboBox. Auto complete queries the data store as the user types into the field. Both local, and remote (AJAX) searches are supported. With auto fill, as the user types, the first matching selecting is appended to the current entry in the text field.

Portals

Portals
Portal is a custom layout container that uses a multi-column layout on contains Portlets. Each Porlet can be drag and dropped to change order or move to another column. Each Portlet can contain any content and supports icons to expand / collapse, close, etc.

Web Desktop

Web Desktop
The desktop mimics the behavior of the operating system look at feel. It is now possible to create multi-window applications with support for a task bar and start menu. Windows support normal, maximize, and minimize states. The start menu is a custom menu that allows new menu items. In addition, there is support for a “task” area for adding additional items.

Slate Theme

Slate Theme
The popular Slate Theme is included with this release. Many thanks to J.C. Bize for donating the theme to Ext JS.

Java Bean Support with BeanModel

The Ext GWT Store and Binder API work with ModelData instances. The primary goal of ModelData is to provide a type of “introspection” as GWT does not allow runtime inspection of Java objects. You can query ModelData for a list of properties it contains, and these properties can be retrieved and set using the parameter name with the get and set methods.

Although this approach works, it forces you to either implement the ModelData interface in your Java Beans or extend the Ext GWT base classes that implement the ModelData interface. What is missing is a way to use your Java Beans as is, without having to extend the Ext GWT base classes or implement an “invasive” interface.

With the 1.1 release of Ext GWT, it is possible to use any Java Beans in the Store and Binder API. This allows you to send your Java Beans from server to client using GWT RPC. More information can be found in this blog post.

Notable New Examples

Now included in Ext GWT 1.1, is a new Samples Demo application. Unlike the Explorer Demo, each of the examples in the demo can be opened individually, with each example having its own HTML file. The same example code and data model is shared between both demo applications.

Forum Search

Forum Search
Forum search is an example of a combo box, using a custom XTemplate, and remote data. The data can be paged with built-in support for a paging toolbar.

Image Chooser

Image Chooser
This example shows loading a ListView in a Window. Each item has a linked details view, and the ListView supports custom sorting and filtering.

Anchor Layout Dialog

Anchor Layout Dialog
This example shows a Dialog using an AnchorLayout to “anchor” the form fields to the dialog dimensions. When resized, the fields will adjust their size to match the dimensions of the dialog.

See the 1.1 release notes for more information on this release.

We are very happy with this release and hope that it will provide a lot of value to our community. We have begun work on 1.2 so you can expect more great features included drag and drop support in the near future.

Download Ext GWT 1.1

Ext JS at The Ajax Experience

Monday, September 15th, 2008

Come join Jack Slocum and I for two developer focused sessions, “Hands On Ext” and “Advanced CSS and Theming of Ext JS” at The Ajax Experience at the end of this month. Feel free to follow along with your laptop or watch as we build an application and demonstrate how to create a custom theme in each hour long session. The Ajax Experience is a three day conference with many interesting sessions on Ajax, Web 2.0 technologies and JavaScript frameworks targeted at developers. This year’s conference will be held in Boston, MA from September 29th to October 1st. Registration is still open and we are hoping to see you there!

Session: Hands on Ext

Speaker: Aaron Conran
Duration: 1 hour
Hands On Ext will be a fast-paced session in which we will build an Ext application in less than an hour. This session will demonstrate how to get started using Ext JS and show how quickly you can put together a simple application from scratch. Learn how to utilize Ext’s high-level UI widgets like GridPanel, TabPanel and FormPanel instead of re-inventing the wheel.

Session: Advanced CSS And Theming of Ext

Speaker: Jack Slocum
Duration: 1 hour
Join Jack as he demonstrates how to manipulate the look and feel of Ext to integrate seamlessly with your application or company’s style guide. As you probably know, all Ext widgets can be transformed to look radically different simply by adding an additional CSS theme file. Learn how to create a custom theme for your Ext application step by step in this hands-on demonstration.

Meet Up

Jack and I are hoping to meet with members of the Ext community to discuss our plans and the future of Ext. We’d also like to find out more about what you guys are creating with Ext. We are planning on having a meet-up after the conference on the 2nd day (Sept. 29th). If you’d like to meetup please send your contact information to meetup@extjs.com. Feel free to suggest a location if you know of a good spot to meet.

We’re Growing

Ext is a growing company and we are looking for talented developers to join our team. Please take a look at jobs.extjs.com if you have the skill set, drive and desire to join our team and grow with us. If you will be at The Ajax Experience, make an additional note so that we can be sure to meet you. The Ajax Experience should be a very exciting conference with many different frameworks and technologies represented. Please be sure to stop by our sessions and the meet-up if you are already an Ext developer or want to know more about Ext. Finally, we’d like to thank the Ajaxians for inviting us to present at The Ajax Experience.

Google Contacts: Creating a Google Chrome App with Ext and the Google Data API

Tuesday, September 9th, 2008

When Google Chrome was released last week, I was interested in seeing how the Application mode feature worked. I revived an old project to interface with the Google Contacts Data API and built a small application to manage your google contacts which you can ‘install’. The example extends the Ext.data.DataProxy to allow you to populate a store with your contact information to bind to any store driven components such as Grid, EditorGrid, ComboBox and DataView. Google Contact Manager

Google Contact Manager

Google Contact Manager will show and allow you to edit the title, primary email and primary phone of all your contacts. At this time there is nothing special that you need to keep in mind when developing a Google Chrome Application. To ‘install’ an application, select the Page icon to the right of the URL box and choose “Create Application shortcuts…” You can then choose to create shortcuts on your Desktop, Start Menu or Quick Launch bar. I chose to create the shortcut on my Desktop. Hopefully Google releases an additional API or a 3rd party plugin which allows you to integrate your web app with more desktop like features. How to Install Google Contact Manager

Working with the Google Data API

This example interfaces directly with Google’s Data API with no need for a server-side backend. Google has released a JavaScript developer guide which is very useful when interfacing with their API. The example authenticates using Google’s AuthSub proxy to obtain the contact information. The authentication token is stored as a cookie with a two-year expiration. One additional caveat when using the Google JavaScript API is that you must have an image hosted at the same domain as your page or it cannot authenticate. Google has recently released many different Data API’s which you can interact with directly through JavaScript including a Language Translation API, a Visualization API and a Notebook API.

Google Chrome’s Future

Google Chrome seems like it will be a game-changing step made by Google for the browser environment. If they kept this project secret for nearly 2 years, I wonder what else they have up their sleeves. I am eagerly awaiting the stable release of Google Chrome as well as the Linux and OS X versions. Google Chrome is currently in Beta and therefore it is not yet an officially supported browser. We have full intentions of bringing Google Chrome into our supported platforms and have created an issue tracking thread on the forums.