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
    sasklacz is on a distinguished road

      0  

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

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      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
    17,167
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      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
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 2

Tags for this Thread