1. #1
    Sencha User AkashSaikia's Avatar
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    33
    Answers
    1
    Vote Rating
    0
    AkashSaikia is on a distinguished road

      0  

    Default Unanswered: Issue while removing and adding a component in the same parent

    Unanswered: Issue while removing and adding a component in the same parent


    Hi all,

    I am facing a problem for a while now.

    Description :
    When i am trying to add a component in the same parent container, with differennt index position, it is not updating the layout. The component that must be their at new place remains at the same position.


    Code is like this :
    Code:
     parent.add(childNew.index  , child);

    Does anybody has idea about it, why is it doing wrong? Or am I missing something.

    Thanks...
    Last edited by AkashSaikia; 17 Jul 2012 at 6:00 AM. Reason: typo

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,095
    Answers
    3503
    Vote Rating
    855
    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


    add only accepts one argument and that is the component instance or config object. It looks like you are trying to pass an index and then the component which is not valid. You should look at the insert method instead.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User AkashSaikia's Avatar
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    33
    Answers
    1
    Vote Rating
    0
    AkashSaikia is on a distinguished road

      0  

    Default



    This is the code inside container :
    Code:
    add : function() {
    Code:
            var args = Array.prototype.slice.call(arguments),
                index = -1;
    
    
            if (typeof args[0] == 'number') {
                index = args.shift();
            }
    ...
    .....
    


    So i pass two arguments to the add method
    Code:
    parent.add(newIndex, oldChild);
    And internally sencha is fetching these two arguments.


    And the insert method internally does the same thing, it calls the add method
    this is sencha code ....
    Code:
     insert : function(index, comp){
            return this.add(index, comp);
        },

    Thanks.


  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,095
    Answers
    3503
    Vote Rating
    855
    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


    Been out of ST1 for too long.

    Is the child destroyed? Like did you remove the item and let it be destroyed?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User AkashSaikia's Avatar
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    33
    Answers
    1
    Vote Rating
    0
    AkashSaikia is on a distinguished road

      0  

    Default


    Yes i know that

    And No.

    I am not destroying the component.

    I am just calling the add method. And as per what i trace, when calling the add method to a component that is already added in some component, sencha tries to remove the component from the previous parent and adds into the new parent.

    If the parent are different it works fine.

    In case of same parent, this procedure of replacing the component also works fine, it adds the keys into new parent at new place, it adds into the items array of the parent compoent.

    But incase of same parent, in doComponentLayout, inside into the deep , there is a method named moveItems

    This method is what i think is culprit.
    moveItems checks that whether the parent are same or not by calling !isValidParent()
    In this case the parent is valid as the component is added into same parent, so it does not replaces the dom from the previous position to new position no matter the actual component and their references are at new position in the items and keys array.


    Thanks.

Thread Participants: 1

Tags for this Thread