0
votes

Using ExtJs 4.1

Hi, I have a field in my model, where

1 = "Ford"

2 = "GM"

3 = "Honda" ...

How to display the names in the grid, when my store has the numbers?

2

2 Answers

3
votes

If you look at the docs there is an example of using templatecolumn: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.column.Template

Basically a template column has access to the record during its rendering. If your record has both the numerical names and descriptive you can print both out to display them (just like in the example).

If your record has no descriptive data then you don't need a template column. You would use a renderer on a regular column and pull and return the description from a lookup object that has the numeric to descriptive labels map. Like this return lookup[value]; Read the docs please for usage of renederer.

1
votes

Use the rendrer on th column

renderer: function(val){
        switch (val){
                case 1: val="Ford"; break;
                case 2: val="GM";break;
                //................
          }
       return val;
    },