View Full Version : newbie question : get the id of a record

14 Dec 2010, 5:21 AM
I try to get the id of a record which is phantom this way :

var id = record.get('id');

but the result is undefined. Is it normal ? How can I get the id ?

Thank you in advance for your answers

14 Dec 2010, 5:26 AM

14 Dec 2010, 5:29 AM
or if it really has none yet (check in firebug console)

* Generates a sequential id. This method is typically called when a record is {@link #create}d
* and {@link #Record no id has been specified}. The returned id takes the form:

PREFIX : String
* (defaults to 'ext-record')

AUTO_ID : String
* (defaults to 1 initially)


* @param {Record} rec The record being created. The record does not exist, it's a {@link #phantom}.
* @return {String} auto-generated string id, "ext-record-i++';
Ext.data.Record.id = function(rec) {
rec.phantom = true;
return [Ext.data.Record.PREFIX, '-', Ext.data.Record.AUTO_ID++].join('');

i never used this one though since phantoms should have an auto id and you can set idProperty in the reader if you want to use your own ones.