2 Replies Latest reply on Aug 16, 2008 4:09 AM by amthekkel

    displaying associated name for a foreign key in a data grid

    amthekkel
      hi all,
      i have two tables one containing shifts and one containing shiftType. the shift table contains a foreign key to shiftType table. I am getting the date from these tables as xml, from a ruby on rails application.
      On the flex side, i have two data grid, one that shows all the shifts and the other that shows all the shift types. I have the xml data for shifts stored as XMLListCollection called shiftXLC and similary i have stored the xml data for shiftType as XMLListCollection called shiftTypeXLC.
      i provide the first datagrid with the shfitXLC collection and displays the values. the only problem is since the shift xml data has a column called "ShiftType_ID" which is contains the foreign key to "ShiftType" table and contains a GUID. So this datagrid shows in its ShiftType_ID column a GUID which is not ideal for a user.
      what i would like to be able to do is to display the actual shifttype name for the associated shiftType_ID. I can display the information using an itemrendrer for that column and using a combobox that displays the ShiftTypeXLC as dataprovider and LabelField="ShiftTypeName".
      Is there a way to do this using a text control so that there is no awkward combo boxes hovering in the datagrid.

      many thanks,

      abhi
        • 1. Re: displaying associated name for a foreign key in a data grid
          Level 7

          "amthekkel" <webforumsuser@macromedia.com> wrote in message
          news:g84362$bo1$1@forums.macromedia.com...
          > hi all,
          > i have two tables one containing shifts and one containing shiftType. the
          > shift table contains a foreign key to shiftType table. I am getting the
          > date
          > from these tables as xml, from a ruby on rails application.
          > On the flex side, i have two data grid, one that shows all the shifts and
          > the
          > other that shows all the shift types. I have the xml data for shifts
          > stored as
          > XMLListCollection called shiftXLC and similary i have stored the xml data
          > for
          > shiftType as XMLListCollection called shiftTypeXLC.
          > i provide the first datagrid with the shfitXLC collection and displays the
          > values. the only problem is since the shift xml data has a column called
          > "ShiftType_ID" which is contains the foreign key to "ShiftType" table and
          > contains a GUID. So this datagrid shows in its ShiftType_ID column a GUID
          > which
          > is not ideal for a user.
          > what i would like to be able to do is to display the actual shifttype name
          > for
          > the associated shiftType_ID. I can display the information using an
          > itemrendrer
          > for that column and using a combobox that displays the ShiftTypeXLC as
          > dataprovider and LabelField="ShiftTypeName".
          > Is there a way to do this using a text control so that there is no awkward
          > combo boxes hovering in the datagrid.

          One way to do it is to have your XML that comes back (and I don't know how
          ruby on rails handles this, but it can't be that different from other
          technologies) be based on a query that joins the shift and shiftType tables
          so that the shiftTypeName is also contained in the shiftXLC. Then you can
          display it as you usually would display any bound data.

          You could also use a labelFunction to look up the shiftTypeName in the
          shiftType XMLListCollection and return the appropriate name.

          HTH;

          Amy


          • 2. Re: displaying associated name for a foreign key in a data grid
            amthekkel Level 1
            hi Amy,

            thanks for the suggestion. I managed to get the required functionality using the labelFunction tip you had mentioned. I also agree with you that trying to get the xml data from Ruby on rails would have been the easier option and i was already trying to do that but was struggling with it. I am new to Ruby on rails as well, so its a new learning curve in for both flex and ROR.

            But thanks anyway for your reply.

            cheers,
            abhi