1. #1
    Sencha - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,352
    Vote Rating
    32
    arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough

      0  

    Default Changing order of items in Panel()

    Changing order of items in Panel()


    Is there a way to change the order of the items contained in an Ext.Panel() object?

    I've tried the following code:
    PHP Code:
    new Ext.Button({
      
    iconCls'moveUp',
      
    handler: function() {
        var 
    currentIndex thisComponent.items.indexOf(newElement);

        if (
    currentIndex 0) {
          var 
    thisRow thisComponent.remove(newElement);
          
    thisComponent.insert(currentIndex-1thisRow);
        }
      }
    }); 
    ...which removes the correct element and adds a blank element in the correct place. So it kind-of works, but not really. It's just not adding the actual element it removed...

    Any ideas would be much appreciated.
    Last edited by arthurakay; 17 Mar 2009 at 6:46 AM. Reason: added extra clarity to the post
    Arthur Kay
    Developer Relations Manager, Sencha Inc.

    Twitter | Sencha Chicago User Group

  2. #2
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    What kind of components are you moving? Did you try to use doLayout() afterwards?
    "kind of works" doesn't help someone know what isn't working about it BTW.

  3. #3
    Sencha - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,352
    Vote Rating
    32
    arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough

      0  

    Default


    True... "kind of works" wasn't a good description. I should know better than that

    Basically what I have is a Panel() object containing a dynamic number of Toolbar() objects. Imagine it looking like a grid, each line having buttons (hence the need for Toolbar() objects):

    Code:
    Object number 1 [move up] [move down] [delete]
    Object number 2 [move up] [move down] [delete]
    Object number 3 [move up] [move down] [delete]
    Object number 4 [move up] [move down] [delete]
    ...
    The objects are drag/dropped onto my panel, so the number of these Toolbar() items is dynamic.
    Arthur Kay
    Developer Relations Manager, Sencha Inc.

    Twitter | Sencha Chicago User Group

  4. #4
    Sencha - Services Team arthurakay's Avatar
    Join Date
    Sep 2008
    Location
    Antioch, IL
    Posts
    1,352
    Vote Rating
    32
    arthurakay is a jewel in the rough arthurakay is a jewel in the rough arthurakay is a jewel in the rough

      0  

    Default


    So when you hit the [move up] button, the correct element is removed from the DOM and (I'm trying) to insert that element at index-1 in the array.

    The problem is that the element I've removed isn't inserted... a blank DOM element is. I'm betting that's because the DOM element has technically been destroyed, so I need a better way to do this.

    Does that make more sense?
    Arthur Kay
    Developer Relations Manager, Sencha Inc.

    Twitter | Sencha Chicago User Group

Thread Participants: 1