Results 1 to 5 of 5

Thread: get id of the inserted record

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Location
    ukraine
    Posts
    13

    Default get id of the inserted record

    Hello everyone.

    got an create function:

    PHP Code:
    onCreate: function(eform) {        
     
    values form.getValues();
     
    this.getManifactorsStore().insert(0values)                
     
    console.log(this.getManifactorsStore())


     
    console.log(this.getManifactorsStore().data.items[0].data.id)
     
    console.log(this.getManifactorsStore().data)
     
    console.log(this.getManifactorsStore().data.items
     
    console.log(this.getManifactorsStore().data.items[0]) 
     
    console.log(this.getManifactorsStore().data.items[0].internalId)  
     
    console.log(this.getManifactorsStore().data.items
      
    console.log(this.getManifactorsStore().data.keys)


    first console.log, if look in browser console and go to
    data.items.0.data.id - here we're got a id of new record
    data.keys.0 - and here

    but if log a this.getManifactorsStore().data.items[0].data.id (second console.log) - the id is null
    and in all other console.logs the id of new record is a null or ext-record-1

    how to get an added record id ?

    find a simular theme without answer - http://www.sencha.com/forum/showthread.php?153025-Get-record-Id-after-insert-to-store


  2. #2
    Sencha User ycuk's Avatar
    Join Date
    Sep 2011
    Posts
    7

    Default

    I think that here so:
    PHP Code:
        store.on('write', function(storeqoperationeOpts){
            
    console.log(operation);
        }); 
    but, it is a bad variant

  3. #3
    Sencha User
    Join Date
    Oct 2011
    Location
    ukraine
    Posts
    13

    Default

    i'm found a solution!!

    you're have to make a timeout.

    so i you make code like this:


    PHP Code:
    var showId = function(store) {
                    
    console.log('timeout')
                    
    console.log(store.data.items[0].data.id)
    }            
    Ext.defer(showId2000this, [store]) 
    everythins is works fine.

    thanks to the http://www.sencha.com/forum/member.php?324607-Romick for founded it




    Maybe some one tell how to do it without timeout ?

  4. #4
    Sencha User ycuk's Avatar
    Join Date
    Sep 2011
    Posts
    7

    Default

    timeout - For me doesn't approach

  5. #5
    Sencha Premium User zmagyar's Avatar
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    94
    Answers
    1

    Default

    Call store.load() after insertion and call your function in the callback. I.e.

    Code:
    store.load(function(records, operation, success){console.log(store.data.items[0].data.id) },this);

Posting Permissions

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