1. #1
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    228
    Vote Rating
    132
    Answers
    3
    seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all

      0  

    Default Unanswered: Extend a model in SA3?

    Unanswered: Extend a model in SA3?


    I was wondering if I could extend a model (different levels in a tree will have different node types, but a common base set of fields) and I came across Extend from custom model class in ExtJS 4. That seems to describe what I want, but my question is, how can I achieve this in SA3?

    To make it easier, here is the code from Stack Exchange:

    Code:
    Ext.define('User', {
        extend: 'Ext.data.Model',
        fields: [
            {name: 'name',  type: 'string'},
            {name: 'age',   type: 'int'},
            {name: 'phone', type: 'string'},
            {name: 'alive', type: 'boolean', defaultValue: true}
        ],
    });
    
    
    Ext.define('BusinessUser', {
        extend: 'User',
        fields: [
            {name: 'businessType',  type: 'string'},
            {name: 'company', type: 'string'}
        ],
    });
    Thanks, Scott

  2. #2
    Sencha Premium Member dawesi's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia (aka GMT+10)
    Posts
    1,083
    Vote Rating
    44
    Answers
    24
    dawesi has a spectacular aura about dawesi has a spectacular aura about

      0  

    Default


    use a 'class' (either drag it from the toolbox, or via the project inspector) and set the extend (which defaults to Ext.Base) to the 'User'

    a global glass such as 'User' isn't good practice, but it does demonstrate the point. ;-)
    Teahouse Training Company
    Official Certified Sencha Trainer

    Australia / New Zealand / Singapore / Hong Kong & APAC



    SenchaWorld.com - Sencha webinars, videos, etc
    SenchaForge.org - (coming soon)
    TeahouseHQ.com - Sencha ecosystem training portal

    Code Validation : JSLint | JSONLint | JSONPLint

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    228
    Vote Rating
    132
    Answers
    3
    seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all

      0  

    Default


    That certainly allows me extend a class, unfortunately SA3 does not then allow me to add fields to the extended class so it looks like this is not being catered for just yet.

    I agree with your comments on 'User'; it was a contrived example.

    Thanks for replying.

  4. #4
    Sencha Premium Member
    Join Date
    Jan 2014
    Posts
    1
    Vote Rating
    0
    eddie.bush@williams.com is on a distinguished road

      0  

    Default


    I created a base class for all of my Model instances. From there, I'm stuck creating custom classes for my remaining Model instances. Aside from having to tell each custom class that it has a fields property, these custom classes also do not show up in all the various drop-downs you would expect to see Model instances listed.

    I also tried creating an override for Ext.data.Model that would add the fields I want to have on everything, but that did not seem to help. At least, when I assign the Store that represents the Model to a Grid, it does not seem to list columns for those fields after having done "Auto-Column list" on the Grid.

    Do we have an ETA for when this will be fixed? I'm staring down creation of hundreds of Model instances and would like for it to be easier to do than it is.

  5. #5
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    228
    Vote Rating
    132
    Answers
    3
    seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all

      0  

    Default


    Is this likely to be actioned at all? I would be nice to be able to use a common base class for say a treepanel, with models that extend this based on the nodeType. As things currently stand it seems I need to manually repeat the fields from the base class (used on the treepanel) in any other models that will be loaded into the tree. I am guessing this would be possible if coding by hand, but it is not possible using SA.
    Last edited by seade; 11 Sep 2014 at 12:40 AM. Reason: typo

  6. #6
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    228
    Vote Rating
    132
    Answers
    3
    seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all seade is a name known to all

      1  

    Default


    As things currently stand I do not think it is currently possible to implement something like the heterogeneous tree Kitchen Sink example using SA. This is my requirement, is there a way to do in is SA 3.1 that I am not seeing?