PDA

View Full Version : Change the id of the record



simon
16 Nov 2009, 12:48 AM
When I create a new record i don't know the id of the record, so it is generated automatically.
After the user set's all required data for the record, it's send to the database and get's an id.

Now I would like to know, how can I change the automatic generated id of the record to the real one?
I tried:

record.id = ordId;

but store.getById(ordId) still returns nothing.

Any idea?

thanks,
Simon

Condor
16 Nov 2009, 3:43 AM
The store uses a MixedCollection to hold records. A MixedCollection not only contains an array of the records, but also a list of ids and a map of records by id.

To update all you could use the reMap method, e.g.

record._phid = record.id; // set old id
record.id = newId; // set new id
store.reMap(record);

simon
16 Nov 2009, 7:02 AM
Thank you,

it works now.

regards, Simon