1. #1
    Sencha User
    Join Date
    Jul 2007
    Posts
    12
    Vote Rating
    0
    mdombos is on a distinguished road

      0  

    Default Unanswered: Extending Ext.data.Model

    Unanswered: Extending Ext.data.Model


    Hi All!

    I tried to extend Ext.data.Model to create my own abstract model, but if the model is created via a store, the model hasn't got the functions and properties wich is declared in the new abstract model.

    PHP Code:
    Ext.define('Ext.ux.data.NewModel',{
        
    extend:'Ext.data.Model',
        
    newFunction:function(){
            
    alert('a');
        },
        
    newProperty:'value'
    });

    Ext.define('myModel',{
        
    extend:'Ext.ux.data.NewModel',
        
    fields:['one','two']
    });

    Ext.define('myStore',{
        
    extend:'Ext.data.Store',
        
    model:'myModel'
    });
    var 
    a=new myStore;
    console.log(a.getProxy().getModel().newProperty);
    a.getProxy().getModel().newFunction(); 
    Error message: TypeError: a.getProxy().getModel().newFunction is not a function

  2. #2
    Sencha User
    Join Date
    Sep 2011
    Posts
    35
    Vote Rating
    4
    Answers
    2
    ettavolt is on a distinguished road

      0  

    Default


    Model is a class, and property/function you have added reside in instances of it. You may try to access them like this: store.getModel().prototype.newFunction()