6 Replies Latest reply on Apr 20, 2008 10:16 AM by miaomm

    Putting multiple items into a single column in a datagrid

    Dizzia Level 1
      Okay,
      So I can put information into a datagrid, I can select a row and make sure that it populates that row. I can even make it hit that specific row and column.

      How do I got about having several different buttons all writing in the same column? And perhaps even ordering it? i.e. The column would look like this: buttonOneInput, buttonTwoInput, buttonThreeInput etc etc

      I'd also like to sort the way this information goes in (just being able to sort by alpha right now would be fine, but better yet if I could sort it so button one always was in the front, button two always in the middle, button three always in the end)
      The end application of this is that I need to populate a datagrid with several different button groups, there are 5 groups, each group contains about 10 buttons. The groups need to appear in a specific order in the datagrid, and I need to be able to add as many button's information to the grid as possible.

      After this stuff all goes in, I need to get it back out too. I think I'll be able to figure that part out.

      Now, I know this is a lot of stuff. I don't even know if it's possible, but it seems like it should be, I've been trying to figure it out all day to no avail.

      Any tips / suggestions / code snippets / links to tutorials would be helpful.

      Thanks.
        • 1. Re: Putting multiple items into a single column in a datagrid
          miaomm
          Hay, you need to create a custom component with as many as buttons and input possible and use itemRenderer inside of your datagrid.
          • 2. Re: Putting multiple items into a single column in a datagrid
            Dizzia Level 1
            Do you think you could be more specific or add a code example? I'm really in the dark on what you mean.
            • 3. Putting multiple items into a single column in a datagrid
              Dizzia Level 1
              Okay, forget that I said buttons.

              Lets say I had a bunch of strings that I wanted to drop into a single item. And I wanted them to insert based on alpha order. How would I go about that?
              • 4. Re: Putting multiple items into a single column in a datagrid
                miaomm Level 1
                This time I really did got what you want. What is the single item are you talking about. It seemed you already have those string and I assume they are in the db. Then you should sorted them on the data query like in alpha or the way you want and use the return query as datasource..
                • 5. Re: Putting multiple items into a single column in a datagrid
                  Dizzia Level 1
                  Well, specifically. They're binded data (swfs) I need the ability to add as many of these as possible to a datagrid. I'll be extracting them and using them in a list.

                  So to break it down, I've got a bunch of different strings I need to add to a datagrid item. I need to add these in the proper order. I then need to pop them back out to a list (I know how to do this part).

                  Basically what I'm going on right now, is I'm calling a flashfile.source from a selected item. Then I'm adding it into a datagrid, I just need to know how to add it in without destroying the current items.

                  Would something work where I'd ask for the current data datagrid.selectedItem.column and then also add the new data work?

                  Thanks for your help miaomm, I'd really appreciate some code showing this .
                  • 6. Re: Putting multiple items into a single column in a datagrid
                    miaomm Level 1
                    Sounds like you need a binded ArrayCollection which you can manipulate as the source of your main datagrid. Inside of your datagrid you need a custome component to respond to the undecided items to display.

                    From your selectedIndex to push the data into your ArrayCollection in the right place.

                    So after you pushing new data into the ArrayCollection and then you will be able to change your data in datagrid without "destroying the current item"
                    If you have your data in the ArrayCollection then you can sorting collection on the back with something like
                    var sort:Sort = new Sort();
                    sort.fields=[new SortField("label1",true,true)];
                    yourCollection.sort=sort;
                    yourCollection.refresh();