Example usage for com.google.gwt.visualization.client AbstractDataTable getFormattedValue

List of usage examples for com.google.gwt.visualization.client AbstractDataTable getFormattedValue

Introduction

In this page you can find the example usage for com.google.gwt.visualization.client AbstractDataTable getFormattedValue.

Prototype

public final native String getFormattedValue(int rowIndex, int columnIndex) ;

Source Link

Usage

From source file:com.google.gwt.visualization.sample.customvisualization.client.CustomVisualization.java

License:Apache License

@Override
public void draw(AbstractDataTable dataTable, CustomVisualizationDrawOptions options) {
    grid.clear();/*from  ww  w  .java  2s.  c om*/
    // Apply the drawing options
    if (options != null) {
        grid.getElement().getStyle().setProperty("backgroundColor", options.getBackgroundColor());
    }

    for (int c = 0; c < dataTable.getNumberOfColumns(); c++) {
        grid.setHTML(0, c, "<b>" + dataTable.getColumnLabel(c) + "</b>");
    }

    for (int r = 0; r < dataTable.getNumberOfRows(); r++) {
        for (int c = 0; c < dataTable.getNumberOfColumns(); c++) {
            grid.setText(r + 1, c, dataTable.getFormattedValue(r, c));
        }
    }
    // handle selection
    grid.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            cell = grid.getCellForEvent(event);
            CustomVisualization.this.fireSelectionEvent();
        }
    });
}