Results 1 to 3 of 3

Thread: newbie question : get the id of a record

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    304

    Default newbie question : get the id of a record

    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

  2. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default

    record.id
    Best regards
    Tobias Uhlig

  3. #3
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,751

    Default

    or if it really has none yet (check in firebug console)

    Code:
    /**
     * 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.
    Best regards
    Tobias Uhlig

Similar Threads

  1. Newbie question
    By twright in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 24 Nov 2010, 4:33 AM
  2. Newbie question
    By vitaliys in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 10 Apr 2010, 7:13 AM
  3. [Newbie] Question
    By andreaspag in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 2 Aug 2008, 3:49 PM
  4. newbie question
    By RyanZec in forum Ext 2.x: Help & Discussion
    Replies: 6
    Last Post: 17 Apr 2008, 11:18 AM
  5. Newbie Question
    By dominodivine in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 28 Apr 2007, 4:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •