Page 5 of 5 FirstFirst ... 345
Results 41 to 42 of 42

Thread: Extjs 4 Dynamic Model

  1. #41
    Sencha User
    Join Date
    Mar 2013
    Location
    Ahmedabad, India
    Posts
    15

    Default is there any way to add fields & model both in store config?

    Hi ed,


    is there any way to add fields & model both in store config?


    suppose I am using 1 model for 3 stores & each one has same configs.
    Now at one place I want to add one more fields for 1 store not for all.


    So how can I overcome this problem?


    Thanks,
    Piyush Dholariya

  2. #42

    Default

    Quote Originally Posted by ppnectar View Post
    Hi ed,
    is there any way to add fields & model both in store config?
    I don't think so. It would be also a very bad practice.

    Quote Originally Posted by ppnectar View Post
    suppose I am using 1 model for 3 stores & each one has same configs.
    Now at one place I want to add one more fields for 1 store not for all.
    Extend the model, so you end up with 2 models, see bellow:

    Code:
    Ext.application({
        name : 'Fiddle',
    
    
        launch : function() {
            Ext.define('User', {
                extend: 'Ext.data.Model',
                fields: [
                    {name: 'name',  type: 'string', defaultValue:'yolo'},
                    {name: 'age',   type: 'int', convert: null},
                    {name: 'phone', type: 'string'},
                    {name: 'alive', type: 'boolean', defaultValue: true, convert: null}
                ]        
            });
            
            Ext.define('User1', {
                extend: 'User',
                fields: [
                    {name: 'name2',  type: 'string', defaultValue:'yolo2'},
                ]
            });
            
    
    
            
            var user = Ext.create('User1', {
                id   : 'ABCD12345',
                name1 : 'Conan',
                age  : 24,
                phone: '555-555-5555'
            });
            
            console.log(user.get('name'),user.get('name1'),user.get('name2')); //yolo Conan yolo2
        }
    });
    https://fiddle.sencha.com/#fiddle/15l9

Page 5 of 5 FirstFirst ... 345

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
  •