5 Replies Latest reply on Nov 30, 2008 6:27 AM by Newsgroup_User

    Sorting with comboBoxes

      How can I get a combobox to sort different columns of a datagrid?
      For instance the first item in the combobox would sort the first column in the datagrid and the second item would sort the second column and so on.



      Thanks
      Dave
        • 1. Re: Sorting with comboBoxes
          Level 7

          "dmschenk" <webforumsuser@macromedia.com> wrote in message
          news:ggmg5o$ceg$1@forums.macromedia.com...
          > How can I get a combobox to sort different columns of a datagrid?
          > For instance the first item in the combobox would sort the first column in
          > the
          > datagrid and the second item would sort the second column and so on.

          This might point you in the right direction
          http://www.cflex.net/showFileDetails.cfm?ObjectID=415


          1 person found this helpful
          • 2. Re: Sorting with comboBoxes
            Thanks for your reply. Unfortunately I'm not try trying to filter the data in the columns, I just want to sort it.
            In the example in the original post which is derived from from http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-control-in-fl ex/ .. the buttons do what I am trying to achieve .... my quest is to get the combobox to do same thing as the buttons.
            My guess is that the combobox items need to be bound withe the sortNew and sortOld functions but I've been trying for days now without any luck.

            Thanks
            Dave
            • 3. Re: Sorting with comboBoxes
              Level 7

              "dmschenk" <webforumsuser@macromedia.com> wrote in message
              news:ggp25g$j39$1@forums.macromedia.com...
              > Thanks for your reply. Unfortunately I'm not try trying to filter the
              > data in
              > the columns, I just want to sort it.
              > In the example in the original post which is derived from from
              > http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-con
              > trol-in-flex/ .. the buttons do what I am trying to achieve .... my quest
              > is to
              > get the combobox to do same thing as the buttons.
              > My guess is that the combobox items need to be bound withe the sortNew and
              > sortOld functions but I've been trying for days now without any luck.

              Try something like this:

              private function cbCloseHandler(event:Event):void {
              myLabel.text = "You selected: " +
              ComboBox(event.target).selectedItem.label;
              myData.text = "Data: " +
              ComboBox(event.target).selectedItem.data;
              switch (ComboBox(event.target).selectedItem.label) {
              case 'old':
              sortOld();
              break;
              case 'new'"
              sortNew();
              }
              }
              HTH;

              Amy


              1 person found this helpful
              • 4. Sorting with comboBoxes
                Thanks Amy

                That was the ticket!!

                private function cbCloseHandler(event:Event):void {
                switch (ComboBox(event.target).selectedItem.label) {
                case 'Old':
                sortOld();
                break;
                case 'New'"
                sortNew();

                Dave
                • 5. Re: Sorting with comboBoxes
                  Level 7

                  "dmschenk" <webforumsuser@macromedia.com> wrote in message
                  news:ggsqhr$8lc$1@forums.macromedia.com...
                  > Thanks Amy
                  >
                  > That was the ticket!!

                  You're welcome :-)


                  1 person found this helpful