PDA

View Full Version : How can I use a lookup table with a grid?



gioindo
18 Apr 2007, 2:34 PM
For example:

I have a lookup table with this data:

table: color_lookup
id:1 color_name:red
id:2 color_name:yellow
id:3 color_name:green

The table I am showing in the gird, contains this data:

table: fruits
id:1 fruit:apple color:1
id:2 fruit:pepper color:3
id:3 fruit:banana color:2

How do I cause the fruits grid to display the corresponding color_name instead of the number?

jack.slocum
18 Apr 2007, 2:59 PM
You can plug in a renderer on the column. Below is some code that assumes it is in the middle of a ColumnModel config and there is a variable myList available in the local scope:


header : 'Some Text',
width:100,
renderer : function(value){
return myList[value];
}