In Sencha Touch 2, by default model field 'id' will be unique. but the generated unique id's will contains alpha numeric characters and dashes, but not numeric values. So we can't treat this field as the primary key. Inorder to make 'id' field contains only numeric values, you need to configure the following properties in the Model Class.
idProperty: 'id',
In order for these above configuration properties to work. you need to add this 'Ext.data.identifier.Sequential' class as the requires one in the Ex.Application Class. Let's see the simple UserModel Class implementation with the user properties.
Source Code:
Following is the snapshot with the unique id's generated with integer values by the model field 'id'.
Hope, you enjoyed this Post.
idProperty: 'id',
identifier: 'sequential',
In order for these above configuration properties to work. you need to add this 'Ext.data.identifier.Sequential' class as the requires one in the Ex.Application Class. Let's see the simple UserModel Class implementation with the user properties.
Source Code:
Ext.define('MyApp.model.UserModel', { extend: 'Ext.data.Model', alias: 'model.usermodel', config: { idProperty: 'id', identifier: 'sequential', fields: [{ name: 'id' }, { name: 'username' }, { name: 'password' }, { name: 'email' }, { name: 'status' }] } });
Following is the snapshot with the unique id's generated with integer values by the model field 'id'.
Hope, you enjoyed this Post.
No comments:
Post a Comment