Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Mar 2010
    Location
    Seattle, WA
    Posts
    137
    Vote Rating
    1
    wprater is on a distinguished road

      0  

    Default Ext.data.Model#setFields not Working as Expected

    Ext.data.Model#setFields not Working as Expected


    Documentation states that one can modify the fields for every instal of a Model with code such as:

    A field named bar is not added to the next instance.

    Code:
          Ext.define('TestModel', {
            extend: 'Ext.data.Model',
            config: {
              fields: [
                {
                  name: 'foo'
                }
              ]
            }
          });
          (Ext.create('TestModel')).setFields([
            {
              name: 'bar'
            }
          ]);
          console.log((Ext.create('TestModel')).getFields());
    Except if you look at the source in #updateFields, the fieldsCollection is just a local variable.

  2. #2
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    19
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Thank you for the report.

    Sencha Inc

    Jamie Avins

    @jamieavins

  3. #3
    Sencha User
    Join Date
    Mar 2010
    Location
    Seattle, WA
    Posts
    137
    Vote Rating
    1
    wprater is on a distinguished road

      0  

    Default


    If you have a work around for this, it'd be much appreciated. I've not had time yet to investigate this further.

    Thanks!

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    9
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default


    Hi wprater,

    Sorry for the delayed reply. I feel like the documentation should be improved to explain this, but if you set the fields on a model instance, it should only be reflected on that particular instance. If you want to change the fields for every new instance created of a Model, you should call the method on the Model class. In your example if you change it to the following, it will achieve what you are trying to do.

    Code:
            Ext.define('TestModel', {
                extend: 'Ext.data.Model',
                config: {
                    fields: [{
                        name: 'foo'
                    }]
                }
            });
    
            Ext.setup({
                onReady: function() {
                    TestModel.setFields([{
                      name: 'bar'
                    }]);
    
                    console.log((Ext.create('TestModel')).getFields());
                }
            });
    Hope this solves your problem.

    Best,
    Tommy

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar