Results 1 to 2 of 2

Thread: Extending Ext.data.Model

  1. #1
    Sencha User
    Join Date
    Jul 2007
    Posts
    12
    Vote Rating
    0
      0  

    Default 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
    574
    Answers
    59
    Vote Rating
    74
      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()

Posting Permissions

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