Results 1 to 3 of 3

Thread: Why new nodes are registered by their internalId's only ?

    You found a bug! We've classified it as EXTJS-8493 . 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
    Location
    Warsaw, Poland
    Posts
    38
    Vote Rating
    1
      0  

    Default Why new nodes are registered by their internalId's only ?

    I was investigating some bug that appeared after switching from 4.1.3 to 4.2 regarding Tree structures, and I've found this change in the source:

    4.1.3
    Code:
        registerNode : function(node, includeChildren) {
            var me = this;
    
            me.nodeHash[node.getId() || node.internalId] = node;
            (...)
        }
    4.2
    Code:
        registerNode : function(node, includeChildren) {
            var me = this,
                children, length, i;
    
            me.nodeHash[node.internalId] = node;
            (...)
        },
    I'm wondering what is the advantage of the second approach ? In this case finding nodes by Id's won't work anymore. What if I'm adding a node with know Id and I want to reference it after adding to the structure ? I'm not considering this a bug but rather I'm interested what was the idea behind this change.
    Using ExtGantt / ExtScheduler from Bryntum ? I can help you integrate and implement it.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,553
    Vote Rating
    1272
      0  

    Default

    I think we were moving to have 2 maps, one for internal id and the other for user defined but I have opened a bug in our bug tracker to make sure this gets look at.

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,584
    Vote Rating
    873
      0  

    Default

    The internalId of a model will be set appropriately if you pass an id to it:

    Code:
    Ext.define('Foo', {
        extend: 'Ext.data.Model',
        
        fields: ['id', 'name']    
    });
    
    Ext.onReady(function(){
        
        var a = new Foo({
            id: 1
        });
        
        var b = new Foo();
        
        console.log(a.internalId, b.internalId);
        // Logs 1 "ext-record-1" 
    });
    There's also code to handle the id on the model being changed so it can notify any interested parties, which will be part of the next release.
    Evan Trimboli
    Twitter - @evantrimboli

Tags for this Thread

Posting Permissions

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