1. #1
    Sencha User dewil_de's Avatar
    Join Date
    Mar 2012
    Posts
    28
    Vote Rating
    3
    dewil_de is on a distinguished road

      0  

    Default Unanswered: container removeAll only removes last added containerBlock

    Unanswered: container removeAll only removes last added containerBlock


    Hey,

    I've run into a problem and don't really see a good way out.

    I have a container (vbox) which i populate with another container (dateBlock flex: 1).
    i do this by container.add(dateblock instance).
    When a user clicks a button i want to clear the container and refill it with new dateBlock instances.
    But when i do container.removeAll it only removes the last added item.

    I've tried things like getting all the innerItems and destroying them but that doesn't work either.
    Is there something i'm missing here?

  2. #2
    Sencha - Senior Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,948
    Vote Rating
    953
    Answers
    3623
    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 use removeAll and it removes everything. I would set a breakpoint on the removeAll and walk through the code.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    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 dewil_de's Avatar
    Join Date
    Mar 2012
    Posts
    28
    Vote Rating
    3
    dewil_de is on a distinguished road

      1  

    Default


    Thx for taking your time to look into the problem.

    But i had already solved it, i had declared a itemId on my dateBlock element.

  4. #4
    Sencha Premium Member zmagyar's Avatar
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    94
    Vote Rating
    2
    Answers
    1
    zmagyar is on a distinguished road

      0  

    Default


    Actually there seems to be a bug here. If there are several items using the same itemId in the container then the item list is failing (contains only one item for the multiplied items). I.e.

    Code:
    for (i=0; i<10; i++) {
       cotainer.add([Ext.create('Ext.Label', {
          html: 'My label index:' + i,
          itemId: 'sameId'
       })]);
    }
    Will display 10 label in the container. However container.getItems() will show that there is only one item in the container. Also container.removeAll() will remove the last added item only.

    As there is no assert fired when the same itemId is used in the same scope (as it happens in case of id) then I would assume no such an important features are dependant on this.

  5. #5
    Sencha - Senior Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,948
    Vote Rating
    953
    Answers
    3623
    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


    The error there is duplicate itemIds in the same container. itemIds should be unique in the container.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    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.

  6. #6
    Sencha Premium Member zmagyar's Avatar
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    94
    Vote Rating
    2
    Answers
    1
    zmagyar is on a distinguished road

      0  

    Default


    See last para of the comment. I think if itemId's should be unique then we should have a warning on the console when it is detected.

  7. #7
    Sencha - Senior Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,948
    Vote Rating
    953
    Answers
    3623
    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


    Sure but that won't do anything to fix the issue for you. You also need to know what your application is doing so that you can also prevent this from happening.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Software Engineer
    ________________
    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.

  8. #8
    Sencha Premium Member zmagyar's Avatar
    Join Date
    Mar 2012
    Location
    Budapest
    Posts
    94
    Vote Rating
    2
    Answers
    1
    zmagyar is on a distinguished road

      0  

    Default


    The whole point is that if you can't find any reference in the documentation that itemId must be unique in the container and there is no warning logged on the console then you will waste reasonable amount of time while find it for yourself.

Thread Participants: 2

Tags for this Thread