You should not change the internal id of records, as this may break everything; the value in record.id
is expected by the framework to be the same value as record.get(record.idProperty)
. Instead, you should always use the setter method: record.set("id", 8)
.
But what you are essentially searching for is the defaultValue
configuration on your model field:
fields:[{
name: 'id',
type: 'int',
defaultValue: 8
}]
Please be advised that the field id
gets a special handling in ExtJS, as long as the model's idProperty
defaults to id
. A store can contain only one record with the same non-null value in the field defined by idProperty
, so if you add them all to the same store you end up with only one of the records, and all other ones are deleted. So if you need multiple records with the same id
in the store, you have to change the idProperty
on the model to something else, e.g.
idProperty: 'someNonExistentProperty'
This then may cause issues with store sync
operations. If you only try to set the id
to a fixed value because your backend requires integer id
, and the default id generated for new records by ExtJS is non-numeric (e.g. ext-myModel-1
), you can check out identifier: 'negative'
.