0 Replies Latest reply on Oct 13, 2009 8:28 AM by raybtwo

    DataGrids and Lookup Tables


      I hope someone can point me in the right direction here. I'm new to Flex and am a ColdFusion developer.


      I'm using the Flash Builder beta and the Flex 4 SDK.


      I'm using the Flex Data Services to pull data from my database and display it in a Data Grid. No problem there....the data services kick butt.


      Here however is my issue. The data I am trying to display is from a database table that that uses several look up tables. So for example I have a field in my table called priorityID that contains a numeric value that is linked as a forgeign key to my priority table. The priority table has a priorityID (PK) and a priorityDesc(ription).


      Oviously I would like to be able to display the priorityDesc rather than the priorityID in my data grid. I've firgured out a way to do this but It cannot be the best way to do it. Here is how I'm currently doing it:


              private function priorityLabelFunction(item:Object, column:DataGridColumn ):String
                      if (item.priorityID==1)
                          {return column.dataField = "Low: When resources are available.";}
                      else if (item.priorityID==2)
                          {return column.dataField = "Medium: Before all low priority items.";}
                      else if (item.priorityID==3)
                          {return column.dataField = "High- Addressed after critical requests.";}
                      else if (item.priorityID==4)
                          {return column.dataField = "Critical- Addressed immediately.";}
                          {return null}


      Then I use a labelFunction in the appropriate DataGridColumn. Obviously the major flaw here is that I've hard coded everything, totally defeating the purpose for using a look up table in the first place. The other issue I have is that I can't sort the Priority column in the grid after I apply the labelFunction. Can someone give me a better way of doing this?