tomalex0/SenchaTouch-v2-SqliteProxy — Issue #3: Limitation of using id as idProperty and  fieldname
Author: tomalex0
Created: 2012-03-04 04:17:50+00:00
State: open

If we have table field name as "id" which is a primary key, we will have to mention a dummy name(not a field in table) as idProperty of model and clientIdProperty as "id". The issue is that default idProperty of model is "id" which will always have value like this "ext-record-x". If mentioned config options are not specified in model, id value in table will be like ext-record-1,2,3. But we expect it as integer.

Example

Ext.define("Contacts", {
extend: "Ext.data.Model",

config : {
idProperty : 'uniqueid', // if we have field with name as id, conflicts happens with default idProperty(id) which always have value as ext-record-x
clientIdProperty : 'id',
fields: [{
name: 'firstName',
type: 'string'
}, {
name: 'lastName',
type: 'string'
},{
name: 'id',
type: 'int',
fieldOption: 'PRIMARY KEY'
}, {
name: 'modifyDate',
type: 'string'

}, {
name: 'modifyDateParsed',
type: 'string',
mapping: 'modifyDate', // not working
isTableField: false,//newly implemented to distinguish field
convert: function(value, rec) {

var dt	= Ext.Date.parseDate(rec.get('modifyDate'), "Y-m-d H:i:s")
newval	= Ext.Date.format(dt,'M j, Y, g:i a')
return newval;
}
}],
proxy: {
type: 'sqlitestorage',
dbConfig: {
tablename: 'contacts_tables',
dbConn: Ext.DbConnection.dbConn
},
reader: {
type: 'array'
}
}
},
writer: {
type: 'array'
}
});