Results 1 to 3 of 3

Thread: Extending Ext.tree.Column

  1. #1
    Sencha User
    Join Date
    Oct 2010
    Location
    France
    Posts
    37
    Answers
    2
    Vote Rating
    0
      0  

    Default Answered: Extending Ext.tree.Column

    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:


    Code:
    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:


    Code:
    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,

  2. I wouldn't bother with using initComponent in the case you've described. I'd also advise initial caps for your namespace:

    Code:
    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.

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585
    Vote Rating
    394
      0  

    Default

    I wouldn't bother with using initComponent in the case you've described. I'd also advise initial caps for your namespace:

    Code:
    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.

  4. #3
    Sencha User
    Join Date
    Oct 2010
    Location
    France
    Posts
    37
    Answers
    2
    Vote Rating
    0
      0  

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •