PDA

View Full Version : setDirty() question



bstras21
16 Jan 2012, 10:00 AM
When I console.log(record) this is what I get:




Ext.apply.create.Class


data: Object
dirty: false
editing: false
id: "webApp.model.customModel-ext-record-2"
index: 0
internalId: "ext-record-2"
modified: Object
phantom: false
raw: undefined
store: Ext.apply.create.Class
__proto__: TemplateClass


I can't seem the set the record as dirty, any thoughts? I tried record.setDirty() but I get an error.

mitchellsimoens
16 Jan 2012, 11:11 AM
This worked without an error:


Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'name', type: 'string'},
{name: 'age', type: 'int'},
{name: 'phone', type: 'string'},
{name: 'alive', type: 'boolean', defaultValue: true}
]
});

Ext.setup({
onReady : function() {

var user = Ext.create('User', {
name : 'Conan',
age : 24,
phone: '555-555-5555'
});

user.setDirty();

console.log(user);

}
});

bstras21
16 Jan 2012, 11:50 AM
If I want to set the dirty property to true wouldn't I do this:



Ext.define('webApp.model.timeModel', {
extend: 'webApp.custom.Model',
dirty:true,
fields: [
{name: 'Time', type: 'string'},
{name: 'Number', type: 'string'},
{name: 'DeviceID', type: 'string'},
{name: 'Action', type: 'string'}
],
proxy: {
type:'localstorage',
id: 'timeProxy'
}
});


If so this isn't working for me.

mitchellsimoens
16 Jan 2012, 11:55 AM
No

bstras21
16 Jan 2012, 12:25 PM
Ext.define('webApp.model.timeModel', { extend: 'webApp.custom.Model', fields: [ {name: 'Time', type: 'string'}, {name: 'Number', type: 'string'}, {name: 'DeviceID', type: 'string'}, {name: 'Action', type: 'string'} ], proxy: { type:'localstorage', id: 'timeProxy' }, constructor: function() {
this.callParent(arguments);
this.dirty = true;
}
});I ask because it seems to set the dirty property now but now I get this error:Cannot read property 'isModel' of undefined