manolo / gwt-polymer-elements

Polymer Web Components for GWT. A collection of Material Design widgets for desktop and mobile.
Apache License 2.0
155 stars 49 forks source link

Vaadin-grid Cell Data Renderers strange use in GWT #106

Closed confile closed 7 years ago

confile commented 8 years ago

Due to the vaadin definition: https://vaadin.com/docs/-/part/elements/vaadin-grid/formatting.html You have to set a custom cell renderer as:

var currencyRenderer = function(cell) {
  cell.element.innerHTML = '$' + cell.data;
};
grid.columns[1].renderer = currencyRenderer;

The function argument is marked as cell. Looking at the GWT example here:

            Column column = grid.getColumns().get(0).cast();
            column.setRenderer(row -> {
                Row r = (Row)row;
                int n = Integer.valueOf(""+ r.getData()) % 4;
                String icon = n == 2 ? "star-half" : n == 1 ? "star" : "star-border";
                r.getElement().<Element>cast().setInnerHTML("<iron-icon icon='" + icon + "'>");;
                return null;
            });

The inner function argument is a row instead of a cell.

  1. Why is this mixed here?
  2. r.getIndex()always returns 1
manolo commented 7 years ago

Good catch. We were using a different object, but since both has the getElement method, and they are native elements they were working.