1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    98
    Vote Rating
    6
    Andreas Samjeske is on a distinguished road

      0  

    Default Howto render Grid Cell with data from two fields?

    Howto render Grid Cell with data from two fields?


    In GXT2 I used to have a ListStore of a model containing the fields "unit" and "value". Then I created a Grid using the ListStore and a ColumnModel. The ColumnModel had a ColumnConfig for the "value" field. This ColumnConfig got a Renderer for showing "unit" next to "value" in that column.

    GXT 2 - Code
    Code:
            List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
    
            ColumnConfig valueColumn = new ColumnConfig("value", "value", 100);
            valueColumn.setAlignment(HorizontalAlignment.RIGHT);
            valueColumn.setRenderer(unitRenderer);
            configs.add(valueColumn);
    
            ColumnModel cm = new ColumnModel(configs);
    
            Grid<MyModel> grid = new Grid<MyModel>(ingrStore, cm);
    With the unitRenderer being:
    Code:
        
    public static final GridCellRenderer<MyModel> unitRenderer = new GridCellRenderer<MyModel>() {
            @Override
            public Object render(MyModel model, String property, ColumnData config, int rowIndex, int colIndex,
                    ListStore<MyModel> store, Grid<MyModel> grid) {
                Double value = model.get(property);
                if (value == null) {
                    return "";
                }
                String unit = model.getUnit();
                return value.toString() + " " + unit;
            }
        };

    Question: How to accomplish this in GXT3?

    I know about setCell() and the render-Method there. But Model, Store and Grid aren't accessible over there.

    What I got so far (GXT 3):
    Code:
    ColumnConfig<MyModel, Double> valueColumn= new ColumnConfig<MyModel, Double>(props.value(), 100, "value"); 
    
    valueColumn.setCell(new PropertyDisplayCell<Double>(new DoublePropertyEditor(numberFormat)) {
    
        @Override
         public void render(com.google.gwt.cell.client.Cell.Context context, Double value, SafeHtmlBuilder sb) {
    
            String unit = "unit";//FIXME: How to get unit out of model here?
    
            sb.appendHtmlConstant("<span>" + value.toString() + " " + unit + "</span>");      }
    
        });

  2. #2
    Sencha User
    Join Date
    Sep 2011
    Location
    Canada
    Posts
    19
    Vote Rating
    -1
    jtaekema is an unknown quantity at this point

      0  

    Default


    You can get the model from your list store using the context.

    Code:
    column.setCell(new AbstractCell<Long>() {
        @Override
        public void render(Context context, Long value, SafeHtmlBuilder sb) {
            model = store.get(context.getIndex());
            ...
        }
    });

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,731
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    You could also make the Cell generic on the Model itself, and use the

    Code:
    ColumnConfig<MyModel, MyModel> column = 
        new ColumnConfig<MyModel, MyModel>(new IdentityValueProvider<MyModel>() ...);
    column.setCell(new AbstractCell<MyModel>() {
      @Override
      public void render(Cell.Context context, MyModel value, SafeHtmlBuilder sb) {
        //render with the whole value, invoking any getter you wish
      }
    });

Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi