PDA

View Full Version : ColumnModel in Ext JS 4



matteoli
10 Mar 2011, 2:13 PM
Hi,

I am wondering how to instantiate a ColumnModel of a GridPanel in Ext JS 4? Is this not implemented currently or do I have to use another class?

In Ext JS 3 the following lines worked well but failing in Ext JS 4 with the error that there is no such constructor in this class:



colModel = new Ext.grid.ColumnModel({
defaults: {
align: 'left',
risizable: false,
sortable: false,
width: 150
}
});


Thanks in advance!
Oliver

scottmartin
10 Mar 2011, 3:19 PM
This forum requires that you post the same question at least 4 times before there is a reply.

Regards,
Scott.

matteoli
10 Mar 2011, 10:56 PM
OK, OK.
I thought the preview button would not publish the post to the forum.
sorry.

mankz
10 Mar 2011, 11:07 PM
ColumnModel seems to have been replaced by 'headers'. See this example http://dev.sencha.com/deploy/ext-4.0-pr3/examples/grid/array-grid.html


// create the Grid
var grid = new Ext.grid.GridPanel({
store: store,
columnLines: true,
headers: [
{
text : 'Company',
flex : 1,
sortable : false,
dataIndex: 'company'
},
{
text : 'Price',
width : 75,
sortable : true,
renderer : 'usMoney',
dataIndex: 'price'
},
{
text : 'Change',
width : 75,
sortable : true,
renderer : change,
dataIndex: 'change'
},
{
text : '% Change',
width : 75,
sortable : true,
renderer : pctChange,
dataIndex: 'pctChange'
},
{
text : 'Last Updated',
width : 85,
sortable : true,
renderer : Ext.util.Format.dateRenderer('m/d/Y'),
dataIndex: 'lastChange'
}
],
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
}
});

matteoli
11 Mar 2011, 4:38 AM
That might be. Do you know, what class is behind the headers? I have to instantiate it by myself, because the columns should be initialized by a dynamic backend.

mitchellsimoens
11 Mar 2011, 6:36 AM
A Header extends Ext.Component.
http://dev.sencha.com/deploy/ext-4.0-pr3/docs/api/Ext.grid.Header.html

There is also HeaderContainer that wraps all the Headers which extends Ext.container.Container.
http://dev.sencha.com/deploy/ext-4.0-pr3/docs/api/Ext.grid.HeaderContainer.html

AlxH
11 Mar 2011, 8:31 AM
See this: http://www.sencha.com/forum/showthread.php?125367-Autogrid-Metagrid

rhelms
13 Apr 2011, 4:59 PM
In ExtJs 4 beta2, gridPanel.colModel seems to have been replaced by headerCt, although the generated documentation does not reflect this.

mitchellsimoens
13 Apr 2011, 5:01 PM
Headers are now back to Columns but you still have HeaderContainer. RC should be coming soon

rhelms
13 Apr 2011, 5:05 PM
Awesome. I'm really new to ExtJS, and thought if I'm going to use it long term, I may as well start with the beta. By the time I'm ready to use it commercially, it may be at final release.

Christiand
14 Apr 2011, 2:29 AM
I may as well start with the beta.

I don't understand why. New comers should start with Ext Js 3. It's rock solid and the doc is accurate with proper examples. The little code you will built will be easily upgradeable to 4 when it's finally release with proper documentation and all component finalized.

rhelms
14 Apr 2011, 4:02 AM
It is most likely that I will end up doing some work with ExtJS 3, but ExtJS 4, even in it's beta state, is giving me a much better idea of where it is going.

Especially when it comes to things like extending GridPanel in it's new form, trying to retro fit plugins and features like auto column widths and filters.

At the moment, ExtJS is a learning exercise for me. I've been told it has a steep learning curve, but once you've got that down, it's smooth sailing. Given the choice, I'd rather hit that curve on how ExtJS will be looking going forward, rather than how it once looked. I hope Sencha make the migration process as smooth as possible, but the next best thing is not having to do a migration in the first place.

stevil
15 Apr 2011, 11:01 AM
I don't understand why. New comers should start with Ext Js 3. It's rock solid and the doc is accurate with proper examples. The little code you will built will be easily upgradeable to 4 when it's finally release with proper documentation and all component finalized.

Easily upgradeable with a compatibility layer, which is really a conversion crutch. If we're this close to a release of Ext 4, you're going to have to learn how it does things anyway. Why learn 3 now to have to unlearn it? I say all in for Ext 4!