-
5 Jul 2012 1:52 AM #1
Answered: [2.0.1.1] Why can't I set the id field of a record when I use localstorage proxy?
Answered: [2.0.1.1] Why can't I set the id field of a record when I use localstorage proxy?
I wanna set the id feild by myself, and I'm sure it's unique (it's uuid string generated from server)
Please let me do this!
IL
-
Best Answer Posted by iron9light
Fixed it
1.
before save it.Code:record.phantom = true
You cannot just setwhen you define your Model.Code:phantom: true
Or the phantom will be true when you load your record from localstorage, and this will cause some strange behaviors (try to remove one record)
2.
Code:Ext.define "Ext.ux.data.identifier.UuidIfEmpty", extend: "Ext.data.identifier.Uuid" alias: 'data.identifier.uuidifempty' generate: (record) -> id = record.getId() if (not id or id == 0) @callParent arguments else id
-
5 Jul 2012 6:41 AM #2
Fixed it
1.
before save it.Code:record.phantom = true
You cannot just setwhen you define your Model.Code:phantom: true
Or the phantom will be true when you load your record from localstorage, and this will cause some strange behaviors (try to remove one record)
2.
Code:Ext.define "Ext.ux.data.identifier.UuidIfEmpty", extend: "Ext.data.identifier.Uuid" alias: 'data.identifier.uuidifempty' generate: (record) -> id = record.getId() if (not id or id == 0) @callParent arguments else id
-
5 Jul 2012 7:35 AM #3
Awesome. I was looking into this too so I will save your answer for myself

-
5 Jul 2012 7:38 AM #4
-
5 Jul 2012 7:40 AM #5
-
5 Jul 2012 8:11 AM #6
You cannot just set
when you define your Model.Code:phantom: true
Or the phantom will be true when you load your record from localstorage, and this will cause some strange behaviors (try to remove one record)


Reply With Quote