3
votes

Let us assume, there is a JsonStore :

SomeStore = Ext.extend(Ext.data.JsonStore, {
  constructor: function(cfg) {
    cfg = cfg || {};
    OrdersStore.superclass.constructor.call(this, Ext.apply({
      storeId: 'someStore',
      url: 'someUrl',
      root: 'rows',
      fields: [
        {
          name: 'someId'
          defaultvalue : '100'
        }
      ]
    }, cfg));
  }
});

How can I do this:

new SomeStore().getFieldByname('someId').setDefaultvalue = '73'

What is the proper syntax for this?

2

2 Answers

3
votes

someStore.fields.item('someId').defaultValue = 73;

0
votes

"someStore.fields" comes up as "null" for me (version 6.2.0).

While it may be possible to go through the store directly to do this, going through the model is working well to update a field's defaultValue just before creating a new record:

someStore.getModel().getField('someId').defaultValue = 73

NOTE: I've found this only works if the defaultValue parameter was used when the field was defined in the first place. If not defined initially, even as 'null', setting it later does not work for me.