1. #1
    Sencha Premium Member
    Join Date
    Jul 2007
    Location
    Sydney, Australia
    Posts
    138
    Answers
    2
    Vote Rating
    6
    seade is on a distinguished road

      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,082
    Answers
    24
    Vote Rating
    41
    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
    138
    Answers
    2
    Vote Rating
    6
    seade is on a distinguished road

      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.