PDA

View Full Version : Extending Ext.tree.Column



ero
4 Sep 2011, 12:27 AM
Hello,


I noted in the documentation for Ext.tree.Column that: "NOTE This is a private utility class for internal use by the framework. Don't rely on its existence."


However, I have an app that uses treepanel to display various data sets depending on the user selection. While each data set is different, each report has some common columns. For that reason I have chosen to define some columns so that I can re-use the code.


So for example, I am defining a column something like this:




Ext.define('app.view.columns.Sample', {
extend: 'Ext.grid.column.Column'
,alias: 'widget.sampleColumn'


,initComponent: function( ) {


Ext.apply(this, {
text: "Sample"
,dataIndex: "sampleCol"
,sortable: false
,align: "right"
,width: 50
});

this.callParent(arguments);
}


});

This works fine and I'm able to do the same for a treecolumn as follows:




Ext.define('app.view.columns.TreeSample', {
extend: 'Ext.tree.Column'
,alias: 'widget.treeSampleColumn'


,initComponent: function( ) {


Ext.apply(this, {
text: "Tree Sample"
,dataIndex: "treeSampleCol"
,sortable: false
,align: "right"
,width: 50
});

this.callParent(arguments);
}


});



So I have two questions:
1. If we should not use Ext.tree.Column, then what should we use? I tried Ext.grid.column.Column, but that did not seem to work - I may be missing something though.
2. If I stick with extending Ext.tree.Column, then what might the risks be?




Thank you,

skirtle
4 Sep 2011, 3:37 PM
I wouldn't bother with using initComponent in the case you've described. I'd also advise initial caps for your namespace:


Ext.define('App.view.columns.Sample', {
extend: 'Ext.grid.column.Column',
alias: 'widget.sampleColumn',

text: "Sample",
dataIndex: "sampleCol",
sortable: false,
align: "right",
width: 50
});

To your actual question, extending tree column is fine. Not sure why it's been marked as private as you can't make a tree grid without it. Sure it's possible that a future version may rename or remove it but that doesn't justify putting in lots of speculative work now to try to defend against such a problem.

ero
5 Sep 2011, 7:44 AM
Thanks for the input skirtle.

As for the code snippets, I just dropped in a quick sample - I have some other things going on in the actual code.