PDA

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



flamant
14 Dec 2010, 5:21 AM
Hi,
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

tobiu
14 Dec 2010, 5:26 AM
record.id

tobiu
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}-{AUTO_ID}.

*
PREFIX : String
Ext.data.Record.PREFIX
* (defaults to 'ext-record')


*
AUTO_ID : String
Ext.data.Record.AUTO_ID
* (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.