Reputation: 1800
When a new entry is added to a store in ExtJS 6.2 it automatically creates a new ID with the name of the model and a numeric ID (MODEL-ID) if you didn't specify any field as ID.
Is it possible to make the store generate IDs only containing the number?
Fiddle: https://fiddle.sencha.com/#fiddle/3gk0&view/editor
Instead of User-1
, User-2
, User-3
, only have 1
, 2
, 3
.
Upvotes: 0
Views: 456
Reputation: 9829
You need to add a custom identifier
setting to the model, see below. This will set the id
property which is added by default to the Model
even if you don't list it among fields:
Ext.define('User', {
extend: 'Ext.data.Model',
identifier: {
type: 'sequential',
seed: 1,
increment: 1
},
fields: [{
name: 'age',
type: 'int'
}, {
name: 'name',
type: 'string'
}, {
name: 'email',
type: 'string'
}, {
name: 'phone',
type: 'string'
}],
});
But keep in mind that these are phantom identifiers, meaning only exist on the client. In most cases servers generate real id fields, and clients get these from servers.
Upvotes: 2