You found a bug! We've classified it as a bug in our system. We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    J4y is on a distinguished road

      0  

    Default [EXTJSIV-3455] Store: get index of record after add

    [EXTJSIV-3455] Store: get index of record after add


    hey,
    i tried to get the index of a record i added to store.
    But if i do a store.indexOfId(...) after store.add(...)/store.insert(...), it always returns "-1"...

    thx for help,
    j4y

  2. #2
    Sencha User pdesmet's Avatar
    Join Date
    Mar 2011
    Location
    belgium
    Posts
    45
    Vote Rating
    0
    pdesmet is on a distinguished road

      0  

    Default


    The record doesn't have an index but if you do an add the index will be 0. (Ext.data.Store-method-add)

    If you do an insert then you can define the index. Ext.data.Store-method-insert

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    J4y is on a distinguished road

      0  

    Default


    Thats not the problem
    The record is definitely added to store. Also if i define a special index with store.insert, the record was successfully added to store (its displayed in dataview).

    The problem is, that store.indexOfId() or store.indexOf() returns "-1", althought record is in store

  4. #4
    Sencha User pdesmet's Avatar
    Join Date
    Mar 2011
    Location
    belgium
    Posts
    45
    Vote Rating
    0
    pdesmet is on a distinguished road

      0  

    Default


    That is because the store doesn't add an index to it.
    If you look at it in firebug, in your console, you will see the records but you will see that the added row has no index.
    Maybe this is a bug or maybe it was intented.

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    J4y is on a distinguished road

      0  

    Default


    i can't see any reason why it could be intented

    maybe anybody has got another solution for my problem:

    The store is used in an Ext.view.View.
    After adding a new record to store, i want to select that new record in dataview automatically....

  6. #6
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    @J4Y-

    Can you post how you are creating the record, and what ID you are using when calling store.indexOfId(??)?
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  7. #7
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    J4y is on a distinguished road

      0  

    Default


    The store has no model definition (using fields-property), so i don't create record with Ext.create...
    PHP Code:
    App.getNavigationStore().add({
      
    id'view_quicksearch',
      
    name'Suchergebnisse'
    });
    App.getNavigationPanel().select(App.getNavigationStore().indexOfId('view_quicksearch')); 
    But i also have this problem in a grid where i create a new instance of a model...

  8. #8
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    @J4y--

    This is a bug.

    in the absence of a formal Model definition(fields config), the idProperty defaults to 'id'. But the ModelManager.create method does not yet consider that. Use this override while we get this fixed:

    Code:
    Ext.ModelManager.create = function(config, name, id) {
            var con = (typeof name == 'function') ? name : this.types[name || config.name];
    
            return new con(config, id || config[con.prototype.idProperty]);
        };
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  9. #9
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    J4y is on a distinguished road

      0  

    Default


    thx dude, you saved my day
    but this occurs also with a formal model definition:
    PHP Code:
    var model Ext.ModelManager.create({}, GLOBALS.MODEL_NAME_EMPLOYEE);
    ....
    update fields....
    Ext.getStore(GLOBALS.STORE_ID_EMPLOYEE).insert(0model);

    alert(model.get('id'));
    alert(Ext.getStore(GLOBALS.STORE_ID_EMPLOYEE).indexOfId(model.get('id'))); 

  10. #10
    Sencha User pdesmet's Avatar
    Join Date
    Mar 2011
    Location
    belgium
    Posts
    45
    Vote Rating
    0
    pdesmet is on a distinguished road

      0  

    Default


    Nice to see this became a bug, it was just planning to report this bug.