1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    492
    Vote Rating
    1
    abcdef is on a distinguished road

      0  

    Default Get all nested properties in a flat list of properties?

    Get all nested properties in a flat list of properties?


    I am looking to do the following:
    I have an object with potentially nested properties in it. I have another object with flat properties in it. The first object shares certain property names with the second, and I would like to take the value from the second object for the matched properties and update the corresponding property in the first object with it.

    Thanks in advance..

  2. #2
    Sencha User
    Join Date
    Jan 2008
    Location
    FL
    Posts
    47
    Vote Rating
    0
    Ant1105 is on a distinguished road

      0  

    Default


    Sounds like you are trying to do something like this...

    PHP Code:
    var obj1 = {
        
    firstName'Foo',
        
    lastName'Bar',
        
    address: {
            
    address1'1234 Something Lane',
            
    city'Some City',
            
    state'Some State'
        
    }
    };

    var 
    obj2 = {
        
    firstName'Bar',
        
    lastName'Foo'
    };

    Ext.apply(obj1obj2); 

  3. #3
    Sencha User
    Join Date
    Mar 2010
    Posts
    492
    Vote Rating
    1
    abcdef is on a distinguished road

      0  

    Default


    Quote Originally Posted by Ant1105 View Post
    Sounds like you are trying to do something like this...

    PHP Code:
    var obj1 = {
        
    firstName'Foo',
        
    lastName'Bar',
        
    address: {
            
    address1'1234 Something Lane',
            
    city'Some City',
            
    state'Some State'
        
    }
    };

    var 
    obj2 = {
        
    firstName'Bar',
        
    lastName'Foo'
    };

    Ext.apply(obj1obj2); 
    Thanks for the reply.

    Yes that works for flat properties at the same level on both ends. Is there a way to do this:

    Code:
    var obj1 = {
        firstName: 'Foo',
        lastName: 'Bar',
        address: {
            address1: '1234 Something Lane',
            city: 'Some City',
            state: 'Some State'
        }
    };
    var obj2 = {
        firstName: 'Bar',
        lastName: 'Foo',
        address1: 'some thing different',
        city: 'something different'
    };
    and the changed object be:

    Code:
    var obj1 = {
        firstName: 'Foo',
        lastName: 'Bar',
        address: {
            address1: 'some thing different',
            city: 'something different',
            state: 'Some State'
        }
    };
    Is there an Ext ready way of doing this?

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    No, there isn't. You'll have to do that yourself (e.g. using Ext.apply and/or Ext.copyTo).

  5. #5
    Sencha User
    Join Date
    Mar 2010
    Posts
    492
    Vote Rating
    1
    abcdef is on a distinguished road

      0  

    Default


    Got it..Thanks..

Similar Threads

  1. Problem with nested properties in BaseModel
    By rotschi in forum Ext GWT: Discussion
    Replies: 0
    Last Post: 25 Sep 2009, 7:13 AM
  2. Need help posting nested properties in Ajax request
    By andyatmiami in forum Ext 2.x: Help & Discussion
    Replies: 11
    Last Post: 13 Aug 2009, 9:10 PM
  3. support for nested properties and defaultValue in JsonReader
    By sjivan in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 25 Jul 2007, 10:41 AM
  4. Using a properties Grid in nested layout
    By harish in forum Ext 1.x: Help & Discussion
    Replies: 2
    Last Post: 8 Jan 2007, 11:12 AM

Thread Participants: 2