Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limitation of using id as idProperty and fieldname #3

Open
tomalex0 opened this issue Mar 4, 2012 · 2 comments
Open

Limitation of using id as idProperty and fieldname #3

tomalex0 opened this issue Mar 4, 2012 · 2 comments

Comments

@tomalex0
Copy link
Owner

tomalex0 commented Mar 4, 2012

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'
        }
    });
@tomalex0
Copy link
Owner Author

tomalex0 commented Mar 4, 2012

http://docs.sencha.com/touch/2-0/sou...Ext-data-Model
look for setId this actually adds idProperty("id") to model even if we are not specifying id as field option.

@fricolfe
Copy link

fricolfe commented Oct 2, 2014

You can use identifier config in the model for set the way sencha generate the ids of the store

....
config: {
identifier: {
type: 'sequential',
prefix: ''
},
.....
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants