Blog

Ext JS 4 Grid Components

March 14, 2011 | Brian Moeskau

We’re hard at work getting Ext JS 4 ready. So far we’ve shipped three developer previews, and are aiming to have the final release delivered in the next four-to-six weeks, but hopefully sooner. Our most recent developer preview was the first with the new Ext JS 4 Grid. Our grid components have been rewritten from the ground up for Ext JS 4 and will provide numerous benefits over the 3.x versions. The 4.0 grid includes greatly improved performance and flexibility, so extending it and adding new functionality will be easier than ever. Here's a rundown of the most important new features.

Intelligent Rendering

The Ext JS 3 grid works fantastically well, but it takes the "least common denominator" approach to its rich feature support by always generating the full markup needed by every grid feature (which is overly-heavy in most cases). In Ext JS 4, the default grid has very lightweight markup, and additional feature-specific markup is only rendered as developers enable different features. This is a huge boost both for page rendering speed and overall grid performance.

Standardized Layout

Along with a smarter rendering pipeline, many parts of the new grid have been made into proper Components and integrated into the standard layout management system rather than relying on custom internal markup and CSS. This enables us to unify the grid's rendering process with the rest of the framework, while still retaining a pixel-perfect UI experience.

DataView

The new GridView in Ext JS 4 extends the standard DataView class. This not only minimizes duplicated code internally, it also makes the new grid even easier to customize. Because it extends DataView, the new grid is also able to leverage the same selection models as any view, including non-contiguous selection via keyboard navigation.

Feature Support

In Ext JS 3, it was easy to add new functionality to grids, but there was no single strategy for doing it. Many added features were provided as plugins, but some were provided via subclassing. This made it very difficult (if not impossible) to combine certain features easily.

Ext JS 4 includes a new grid base class called Ext.grid.Feature which provides the basis for creating extremely flexible optional grid features. The underlying grid templates can be modified by any Feature classes in order to decorate or mutate the markup that the grid's view generates. Features provide a powerful alternative to subclassing the old GridView because it makes it easy to mix and match compatible features. Some examples of Features in the new grid are RowWrap, RowBody and Grouping.

Virtual Scrolling

The Ext 4 grid now natively supports buffering its data during rendering, providing a virtual, load-on-demand view of its data. Grids will now easily support hundreds or even thousands of records without paging, which will be a massive improvement over the Ext JS 3 grid's data handling capacity.

Editing Improvements

In Ext JS 3, developers had to use the specialized EditorGrid class to provide an editable grid, which limited its flexibility. In Ext JS 4, there is now an Editing plugin that can be applied to any grid instance, making it completely reusable across all grids. In addition, the popular RowEditor extension from Ext JS 3 has been promoted to a first-class and fully-supported framework component in Ext JS 4.

An Example

Ext JS 4 Grid

Here's the setup of a basic grid with grouping in Ext JS 4. It's impossible to cover all of the new functionality in only one example, but this should give you a good taste of the new grid in action. As you can see, the configuration is very similar to that in Ext JS 3, but the grouping functionality is now a simple feature config, rather than an entire custom GroupingView instance as required in Ext JS 3. This is but one example of the new flexibility in Ext JS 4. Also, grouping is now supported directly in the standard Store, so a separate GroupingStore is not needed either.

Ext.onReady(function() {
   Ext.regModel('Teams', {
       fields: ['name', 'sport']
   });
 
   var teamStore = new Ext.data.Store({
       model: 'Teams',
       sorters: ['sport','name'],
       groupField: 'sport',
       data: [
           { name: 'Aaron', sport: 'Table Tennis' },
           { name: 'Aaron', sport: 'Football' },
           { name: 'Abe', sport: 'Basketball' },
           { name: 'Tommy', sport: 'Football' },
           { name: 'Tommy', sport: 'Basketball' },
           { name: 'Jamie', sport: 'Table Tennis' },
           { name: 'Brian', sport: 'Basketball' },
           { name: 'Brian', sport: 'Table Tennis' }
       ]
   });
 
   var grid = new Ext.grid.GridPanel({
       renderTo: Ext.getBody(),
       store: teamStore,
       width: 400,
       height: 300,
       title: 'Sports Teams',
       features: [{
           ftype: 'grouping'
       }],
       headers: [{
           text: 'Name',
           flex: 1,
           dataIndex: 'name'
       },{
           text: 'Sport',
           dataIndex: 'sport'
       }]
   });
});

There are 76 responses. Add yours.

Michael Camden

1 year ago

Looks great, but I haven’t seen or heard anything about the Locking Grid View. How will the new Grids support this feature?

Larry Leszczynski

1 year ago

With the current grids, we’re getting dinged by accessibility/508 compliance checkers that complain about e.g. missing image ALT text on the little up/down arrows in sortable column headers.  Would love to see that kind of thing addressed with the new version 4 grids.

Thanks!
Larry

Gary Taylor

1 year ago

Virtual Scrolling—does this mean that MindPatterns’ LiveGrid component is no longer needed?

Adam

1 year ago

A few notes about Grid events would be nice.  Something like “You did it this way in v3 and it’s now this way in v4…”.

We’ve had to hunt down threads on the forum to see how (if at all) these are implemented.

Claude

1 year ago

Ext-JS’ core component redux. Can’t wait to use it.

Jim D.

1 year ago

Looks cool but years behind what you can do with Flex smile

Aaron Conran

1 year ago

@Michael - The ground work is in place to support locking functionality. We’ve designed it so that this is going to be easier to implement than it was in the past. It will be coming soon.

@Larry - We are currently working with a team that are accessibility experts in regard to 508 compliance. We’re working on this.

@Gary - I’m not certain; we’d have to review the set of features it provides.

David Marine

1 year ago

I purchased 3.3 back in mid December. Is there a discounted upgrade path to 4?

David Marine

1 year ago

Will the JS file sizes be smaller or larger in 4 as compared to 3.3?

Jens Frandsen

1 year ago

I am guessing complete re-write implies we need to redo/recode all our grids to work with the upgraded JS 4.

Or is there any chance the JS 3 grid code will work with JS 4 frameset?

Incog

1 year ago

Just as Gary mentioned, I’d also like to see some more specifics on the “Virtual Scrolling” and it’s load-on-demand feature. I’d be ecstatic to migrate to Ext JS 4 and no longer be held back on Ext JS 3 solely for the LiveGrid component.

@Aaron: In a nutshell, from it’s wiki page; “Ext.ux.Livegrid is an ExtJS user extension. It’s core functionality is to render large data without the need of paging, realized through intelligent predictive buffering of data from the server.” Can you please comment on how 4’s Grids compare in terms of buffering/rendering/loading/(no) paging.

Sebastien Tardif

1 year ago

The example above is unable to buffer. I means, if you add more data, then at initialization it will freeze when it’s creating the DOM for all the data.

SteveL

1 year ago

@Jim D:  You may have gotten on the wrong bus.  Sencha and ExtJS are all about high quality HTML5 apps.  Flex is dependent on the Adobe Acrobat Player.  Of course something which started a few years prior to Sencha will have greater functionality, but if that were the case then I’d be promoting PowerBuilder’s datawindows for everything wink

HTML5 is clearly the future so hats off to Sencha for working so fast to achieve feature parity with older technologies such as Flex.

Chris Scott

1 year ago

I think the configuration could be better.

- Why supply features through the items collection?  Why not as a mixins?
- Why define “headers” via items?  And why call it headers anyhow?—this is a columns def’n, non? (since it includes #dataIndex).

gongyx414

1 year ago

no things

Tane Piper

1 year ago

ExtJS4 grids are just so much better now - very easy to configure and work with - but I noticed with the grouping feature there is no easy way to add/remove grouping from the grid (http://www.sencha.com/forum/showthread.php?126332-Add-Remove-grouping-feature-from-Ext.grid.GridPanel), although changing the grouping column in the store is easy enough.  But if you just make it empty, the grouping feature is still active on the grid, it’s just empty and looks ugly

Quan Nguyen

1 year ago

I think grids are so cool but i want to ask How about .js is conflict with Microsoft Ajax in ExtJS 4.0?

MajidTaheri

1 year ago

ExtJs4 Does Support Right-To-Left for Grid,etc?

DeyV

1 year ago

Real cool - but why this post is not visible on blog list?

Ed Spencer

1 year ago

@Quan no conflict with Microsoft in 4.x

@Majid that support has been baked into the framework’s infrastructure. We’ll be enabling it as 4.x progresses

@DeyV this is a newsletter article, we tend to open them up on the blog after the newsletter subscribers have seen them first

David Marine

1 year ago

I am going to repost a couple questions I posted a day ago and haven’t gotten an answer to yet:

- I purchased 3.3 back in mid December. Is there a discounted upgrade path to 4?
- Will the JS file sizes be smaller or larger in 4 as compared to 3.3?

Thanks,

- David

David Marine

1 year ago

Okay, I just looked, which I should have before, and found the answer to my upgrade question. Basically I need to buy a support plan for 3.3 to get 4 for free, which is what I will do.

Duke Dougal

1 year ago

Its somewhat disappointing that all this work has been done on the grids but there is still no ability to put filter fields at the top of columns, as seen in these grids:

http://demos.devexpress.com/ASPxGrid…FilterRow.aspx
and here:
http://dhtmlx.com/docs/products/dhtmlxGrid/
and here
http://www.telerik.com/help/aspnet-ajax/grdbasicfiltering.html

Sebastien Tardif

1 year ago

Duke, it’s worst that it seems. The virtual scrolling, implemented as a feature, is not compatible with other features. Feature has tendency to be exclusive, I mean only one feature can be used on a particular grid.

The change from Ext JS 3.3 is almost just that BufferView.js is now a more supported code, packaged as a feature.

http://www.sencha.com/forum/showthread.php?124595-How-and-where-do-apply-the-new-Infinity-Scroll-feature&p=578896.

Sebastien Tardif

1 year ago

Duke, it’s worst that it seems. The virtual scrolling, implemented as a feature, is not compatible with other features. Feature has tendency to be exclusive, I mean only one feature can be used on a particular grid.

The change from Ext JS 3.3 is almost just that BufferView.js is now a more supported code, packaged as a feature.

Duke Dougal

1 year ago

Sebastien - are you saying that the fundamental architecture of the grids in version 4 is wrong?  Do other grids on the market take a better approach?

Sebastien Tardif

1 year ago

All fundamental features like virtual scrolling and column reordering should be baked in the grid and activated by default, so that they end-up working with optional features. Of course, that doesn’t mean the fundamental features should generate markup when they are not used.

Other grids have all their features working at the same time, like SmartClient Grid. It’s unlikely Ext JS 4 has any of its features like grouping, and column locking work with virtual scrolling, or that row expander work with column locking.

Incog

1 year ago

Is this true what Sebastien stated—that Virtual Scrolling cannot simultaneously coexist with other Grid Features such as RowWrap, RowBody and Grouping? If so, that’s highly disappointing.

nayato

1 year ago

It would be nice to see groupers collection being put to work allowing multi-level grouping in ExtJS 4 final release. Is there any plans to support it? otherwise I wonder what was the purpose of its introduction in Store class…

Dan

1 year ago

Are there plans to, instead of simply not rendering the rows in the grid that are not viewable, to not even load those records into the store until they are viewable?  When you bring back thousands of rows, one performance increase is not rendering the rows that people cannot see, but another big part of the performance issue is the initial load of all the data into the store.  Seems like you could do the same kind of thing with loading records into the store as you do with showing only the records that are viewable.

AlxH

1 year ago

Will the ExtJS 4 grid support to change the headers (and store model) on runtime?
Like to create a Dynamicgrid or Autogrid in Ext3.

Bob Obringer

1 year ago

@Jens:  We still have yui-ext 0.33 (thanks Jack!) applications running wrapped in an iframe.  Our Ext 3.3.1 framework drives our entire website and in cases we need to run legacy stuff, we keep the rest of the global 3.3.1 based layout and then just stick our 0.33 apps in an iframe.  We have a standard page that knows how to plug in the legacy stuff @ a url like:  http://example.com/legacyframe?path/to/legacy/app.

All we needed to do was remove the “site layout” pieces of the old apps and left just core application functionality.  Been working perfectly like this for a few years now.


Also… lol at the Adobe troll.  Flex?  My CPU scoffs at the Adobe troll as it cranks away HTML5 apps.  Also… does Flex allow you to create a data model that works with both desktop UI’s as well as phone/tablet UI’s?  Oh, that’s right… Flash STILL doesn’t really run on phones/tablets and when it does… you better hope you can log in before your battery dies.

Alain Ekambi

1 year ago

Great stuff you guys are doing like always.  Keep up the good work Sencha team.
@Bob Oringer I own several androis phone an really never had any problem with flash so stop listening to Steve Jobs smile. Regarding building Flex applications for the desktop and mobile (for devices that supports flash) from the same code basis,  i m building a GWT API for FLEX which will enable you to do just that. you can check it out here : http://code.google.com/p/gwt4air/

sumit.madan

1 year ago

Is Virtual Scrolling available on grids with different row heights?. I currently use grid paging in a application where row heights are different depending on the data displayed. Can Virtual Paging support that?

Tal

1 year ago

Will “features” (and ftypes) be used for other parts of the framework? I’m looking at you TreePanel.

Brian Moeskau

1 year ago

Just in case anyone noticed, as pointed out above by @Chris Scott the original example showed features and headers being under an “items” level in the code.  This was incorrect, and was simply a snafu in porting between working code and the blog post.  There is no “items” level and the example code has been updated accordingly.  Sorry for the confusion!

Justin Noel

1 year ago

I have the same question / concern as @Duke Dougal above.  Does ExtJS 4 not have the ability to filter inline above the columns? 

This is a great feature that is available in several other grid packages.  For example, even the jQuery Plug-in jQGrid has this ability.

I will soon be moving to ExtJs for development and didn’t realize this was not possible.  This is a bit of setback for me.

Jonathan Ferrer

1 year ago

Sencha Team,

Would it be possible to prepare for us a new preview of EXTJS4 with the fix applied to the new version?

Thank you in advance

Ed Spencer

1 year ago

@Duke & Sebastien sorry if it wasn’t clear - we do of course support virtual scrolling + other features at the same time. In fact, the new architecture makes it possible to have far more enabled features per grid than in 3.x - I think the point was that not every possible feature combination can work.

@Justin because grid headers are just containers now that will be pretty easy. I too would like to see it in the framework

@Jonathan PR4 will go out shortly, biggest update yet.

Ed Spencer

1 year ago

@sumit we didn’t compromise on the virtual scrolling - it works with any combination of row heights

Justin Noel

1 year ago

@Ed Spencer : Excellent.  Thanks for clarifying. 

I didn’t mention in my first post, but I am very impressed with ExtJs4.  The charting in particular is beautiful.  I can’t wait to start developing some of our internal dashboards with it.

Jonathan Ferrer

1 year ago

@Ed Spencer Thank you !!

  I’m anxious to know, will we have the new themes(Neptune) in the next update?

thank you

Vladislav Holovko

1 year ago

“...hundreds or even thousands of records without paging…”” sounds like a fairy tale! It would be a breakthrough.

Primadi Setiawan

1 year ago

Can Extjs4 give more example about grid editing ? I want extjs can help me build interface like this is easy: http://www.acumatica.com/GetFile.ashx?fileID=64c2b414-b4a8-4bad-9d32-068801838e49.swf

Thank you smile

Alain Ekambi

1 year ago

I think you can do that with ext js dough, but i m not quiet sure.

Duke Dougal

1 year ago

@EdSpencer I hear your comment that you would also like column header filter fields.  The question is are we likely to see column filter fields any time soon?  It really is something of a puzzle that so much work is being done on new stuff but this absolutely essential functionality for a grid just isn’t there.

James

1 year ago

How about Sub grid?
The previous version couldnt handle it, how about this version 4?

Les

1 year ago

>>>> @Justin because grid headers are just containers now that will be pretty easy. I too would like to see it in the framework

Ed, what’s the problem with adding filtering as suggested by Justin?  You still have a lot of time.  Even jqGrid has this feature.

Sebastien Tardif

1 year ago

@Primadi Setiawan With Ext JS 3.x you can already do what you show in your video, because your video use paging in grid, and doesn’t use filter box on top or below columns, or any other not obvious grid feature.

Alain Ekambi

1 year ago

is something like this available ?
http://www.gwt4air.appspot.com/#com.iwobanas.controls.MDataGrid

a customer from us is evaluating Flex/Ext JS/Ext-GWT and want that feature

Sebastien Tardif

1 year ago

@Alain Ekambi, which feature you are talking about, be able to put a button, then an edit box show up with animation? I believe it’s not much code to be added in Ext JS 3.3.x but it’s not pre packaged.

Alain Ekambi

1 year ago

No i m talking about the live searching at the bottom.
just type in the search box to see it in action

Alain Ekambi

1 year ago

to answer my own question it looks like yes:
http://gridsearch.extjs.eu/

Primadi Setiawan

1 year ago

@Sebastien Tardif How to add custom control to edit column and custom editing behaviour? for example:
- i want to edit specific column value using multiple column combo box, other column using DateEdit..
- i want to prevent edit for specific column based on other column value..
Is it easy to do using extjs4 grid ? plug-in concept is good, but as developer we want complete solution for grid, and dont care about it provided using plug-in or not..

thanks.

morfeusz

1 year ago

How can i turn on virtual scrolling?

Jozef Sakalos

1 year ago

I’m a bit concerned about this chunk of code in TablePanel::initComponent:

var headerCtCfg {
            items
me.headers,
            
sortableme.sortableHeaders
        }
;
        if (
me.hideHeaders{
            headerCtCfg
.height 0;
        
}
        me
.headerCt = new Ext.grid.HeaderContainer(headerCtCfg); 

That means that we cannot provide an alternative HeaderContainer from outside nor configure the standard one (besides headers array, sortableHeaders and hideHeaders).

Shall is stay as it is or you’re going to honor a HeaderContainer set from outside?

Best,
Saki

Duke Dougal

1 year ago

I’m using ext-js4 preview 5 and loading a grid with 20,000 or so records and it’s slow.  It’s not snappy at all.  Any suggestions as to what I can do to make it faster?

Chris Scott

1 year ago

@Duke Dougal How can you expect a grid containing 20000 rows to be “snappy”, let alone usable?  What do you expect a user to do with 20000 rows??  I think you need to think more about providing your users with useful filters than in trying to over-stuff a grid with 20000 rows.

Sebastien Tardif

1 year ago

@Chris Scott   Duke Dougal didn’t explain his exact setup, but 20000 rows does work fine with LiveGrid, SmartClient Grid, jqGrid, and SlickGrid, with the right no paging setup. After all, this blog talk about virtual scrolling, saying and I quote: “thousands of records without paging”, but if I modify the same example of this blog with 1000 rows it’s already starting to show slowness. The fact is that preview 5 do not yet have any executable example using virtual scrolling, so Duke is just confused, and he should be due to this marketing blog.

Duke Dougal

1 year ago

@Chris Scott currently the ext-js grid doesn’t have any column header filters.  Do you have a different sort of filer in mind?  I do need some solution so I’d be keen try try any ideas.

thanks

Aaron Conran

1 year ago

@Duke and Sebastien -

There will be an example coming in the near future with a huge dataset and impressive performance.

Duke Dougal

1 year ago

@Aaron Conran

Sounds exciting.  Can’t wait.

Diego

1 year ago

How can I replicate what it was the Editorgrid in extjs 3.2 with the new grid into 4th version ?
Can someone digit here the code to do this ? I tried following api instructions ... but I can’t.

Andrej Marincic

1 year ago

Can’t wait for final release and some aditional samples grin Good work!

Jonathan Ferrer

1 year ago

Everyone is waiting for that and we hope it’s going to be soon!

Jonathan Hayward

1 year ago

Is there the option to opt-out of “infinite scrolling” and opt-in for paging for those of us that prefer good paging?

Ozone

1 year ago

It seems that “headers” as used in the example are called “columns” after all in your Ext4 beta 2. Is that correct? And neither “headers” nor “columns” are mentioned in the API as Configs yet?

Thanks for a great component by the way - I can’t wait for the final Ext4 release! grin

Raghuram Reddy Gottimukkula

1 year ago

Hi,
I am more excited to implement the infinite scrolling grid in my upcoming project.
While implementing infinite scrolling grid, i am facing problem in converting jsonp format through ColdFusion code
It would be great, if any body share/suggest the code which will generate jsonp format suits to infinite grid callback call similar to http://www.sencha.com/forum/remote_topics/index.php in ColdFusion.
I tried with serializing query data and converting to lower case which is not loading data.

It is working fine, if i changed jsonp type to ajax. But buffering on scroll is not happening.

@Aaron: I am looking for the suggestions/steps to implement infinite scroll grid using ColdFusion.

Thanks,
Raghuram Reddy Gottimukkula
Adobe Certified ColdFusion Professional
Hyderabad India

m101

1 year ago

This sample code does not work for me!!, the bug says, no longer support headers, and use columns instead.
The documents of ext js4 is bit not clear and some how a bit confusing.

Ozone

1 year ago

@m101: Replace the word “headers” with the word “columns” in the code, and you should be on your way grin

Jagan Mohan

11 months ago

Is there a way to configure paging info for the beffering grid.

??

9 months ago

????????????json?????

Cheryl Terydale

9 months ago

@Ozone - thnx for clarity. Also, never saw if an answer was given re: @Jonathan Hayward and infinite paging. Anyone?

Terry Chen

9 months ago

How can I modify the “ftype” ‘s value with a button?
ftype: ‘grouping’——-> ftype: ‘groupingsummary’

Serj Cebotari

9 months ago

@Terry Chen here is how I’m dealing with it :
  var groupSummary = Ext.create(‘Ext.grid.feature.GroupingSummary’, {
  id : ‘groupingsummary’,
  ftype : ‘groupingsummary’,
  groupHeaderTpl : ‘{name}’,
  hideGroupedHeader : true,
  enableGroupingMenu : false,
  showSummaryRow : !toggleValue
  });
 
  var totalSummary = Ext.create(‘Ext.grid.feature.Summary’, {
  id : ‘totalsummary’,
  ftype : ‘totalsummary’,
  showSummaryRow : toggleValue
  });

And in the grid you put this :
  features : [totalSummary, groupSummary]

So the toggleValue decides what feature will be enabled..
If you want to modify this on button click just put this in handler :
  grid.getView().getFeature(‘groupingsummary’).toggleSummaryRow(newVal);
  grid.getView()getFeature(‘totalsummary’).toggleSummaryRow(!newVal);

Comments are Gravatar enabled. Your email address will not be shown.

Commenting is not available in this channel entry.