obwalton
9 Aug 2010, 10:54 AM
I'm at a bit of a loss. I've created Grid objects in my app inside a standard ContentPanel, with content populated via a GWT server call, but I'm now trying to do what I consider fairly simple: display a pre-populated Grid, inside a Dialog object. However, when I do a Dialog "show()", the Dialog and Grid appear with column headings, but there is no content in my Grid.
I've included a snippet of source code below to show how I am creating the Grid and Dialog. If the source for the GeneResult Model object is helpful I can post that as well...
Thanks for any assistance folks can provide.
Dave
---- Snippet of source from my application's EntryPoint ----
// Fetch the list of genes in the region
List<Gene> genes = (List<Gene>) region.getGenes();
// Set up some number formatters for later use.
final NumberFormat meanFmt = NumberFormat.getFormat("#0.00");
GridCellRenderer<QTLResult> formatMean = new GridCellRenderer<QTLResult>() {
public String render(QTLResult model, String property, ColumnData config, int rowIndex,
int colIndex, ListStore<QTLResult> qtlList, Grid<QTLResult> grid) {
int val = (Integer) model.get(property);
return meanFmt.format(val);
}
};
final NumberFormat pvalFmt = NumberFormat.getFormat("#0.0000");
GridCellRenderer<QTLResult> formatPVal = new GridCellRenderer<QTLResult>() {
public String render(QTLResult model, String property, ColumnData config, int rowIndex,
int colIndex, ListStore<QTLResult> qtlList, Grid<QTLResult> grid) {
int val = (Integer) model.get(property);
return pvalFmt.format(val);
}
};
// Define all the columns in the grid
final List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column = new ColumnConfig();
column.setId ("mgiid");
column.setHeader ("MGI ID");
column.setWidth (100);
configs.add (column);
column = new ColumnConfig();
column.setId ("symbol");
column.setHeader ("Gene Symbol");
column.setWidth (100);
configs.add (column);
column = new ColumnConfig();
column.setId ("hrmean");
column.setHeader ("HR Mean Intensity");
column.setWidth (100);
column.setRenderer (formatMean);
configs.add (column);
column = new ColumnConfig();
column.setId ("lrmean");
column.setHeader ("LR Mean Intensity");
column.setWidth (100);
column.setRenderer (formatMean);
configs.add (column);
column = new ColumnConfig();
column.setId ("pvalue");
column.setHeader ("P-Value");
column.setWidth (100);
column.setRenderer (formatPVal);
configs.add (column);
// Now Populate the rows of our store
ListStore<GeneResult> geneList = new ListStore<GeneResult>();
for (Gene gene : genes) {
String mgiId = gene.getMgiId();
String symbol = "";
if (gene.getSymbol() != null) {
symbol = gene.getSymbol();
}
Double hrMean = gene.getHighRespondingMeanIntensity();
Double lrMean = gene.getLowRespondingMeanIntensity();
Double pValue = gene.getPValue();
GeneResult geneResult = new GeneResult(mgiId, symbol,
hrMean.doubleValue(), lrMean.doubleValue(),
pValue.doubleValue());
// add to liststore
geneList.add(geneResult);
}
ColumnModel cm = new ColumnModel(configs);
// Now create our Grid and Dialog to display it in
Grid<GeneResult> geneGrid = new Grid<GeneResult>(geneList, cm);
geneGrid.setStyleAttribute ("borderTop", "none");
geneGrid.setBorders(true);
geneGrid.setStripeRows(true);
Dialog d = new Dialog();
d.setHideOnButtonClick(true);
d.setButtons(Dialog.CLOSE);
d.setBodyBorder(false);
d.setHeading("Genes for Chromosome " + chromosome +
" range " + range);
d.setButtonAlign(HorizontalAlignment.CENTER);
d.setLayout(new FitLayout());
d.setSize(500, 300);
d.add(geneGrid);
d.show();
I've included a snippet of source code below to show how I am creating the Grid and Dialog. If the source for the GeneResult Model object is helpful I can post that as well...
Thanks for any assistance folks can provide.
Dave
---- Snippet of source from my application's EntryPoint ----
// Fetch the list of genes in the region
List<Gene> genes = (List<Gene>) region.getGenes();
// Set up some number formatters for later use.
final NumberFormat meanFmt = NumberFormat.getFormat("#0.00");
GridCellRenderer<QTLResult> formatMean = new GridCellRenderer<QTLResult>() {
public String render(QTLResult model, String property, ColumnData config, int rowIndex,
int colIndex, ListStore<QTLResult> qtlList, Grid<QTLResult> grid) {
int val = (Integer) model.get(property);
return meanFmt.format(val);
}
};
final NumberFormat pvalFmt = NumberFormat.getFormat("#0.0000");
GridCellRenderer<QTLResult> formatPVal = new GridCellRenderer<QTLResult>() {
public String render(QTLResult model, String property, ColumnData config, int rowIndex,
int colIndex, ListStore<QTLResult> qtlList, Grid<QTLResult> grid) {
int val = (Integer) model.get(property);
return pvalFmt.format(val);
}
};
// Define all the columns in the grid
final List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column = new ColumnConfig();
column.setId ("mgiid");
column.setHeader ("MGI ID");
column.setWidth (100);
configs.add (column);
column = new ColumnConfig();
column.setId ("symbol");
column.setHeader ("Gene Symbol");
column.setWidth (100);
configs.add (column);
column = new ColumnConfig();
column.setId ("hrmean");
column.setHeader ("HR Mean Intensity");
column.setWidth (100);
column.setRenderer (formatMean);
configs.add (column);
column = new ColumnConfig();
column.setId ("lrmean");
column.setHeader ("LR Mean Intensity");
column.setWidth (100);
column.setRenderer (formatMean);
configs.add (column);
column = new ColumnConfig();
column.setId ("pvalue");
column.setHeader ("P-Value");
column.setWidth (100);
column.setRenderer (formatPVal);
configs.add (column);
// Now Populate the rows of our store
ListStore<GeneResult> geneList = new ListStore<GeneResult>();
for (Gene gene : genes) {
String mgiId = gene.getMgiId();
String symbol = "";
if (gene.getSymbol() != null) {
symbol = gene.getSymbol();
}
Double hrMean = gene.getHighRespondingMeanIntensity();
Double lrMean = gene.getLowRespondingMeanIntensity();
Double pValue = gene.getPValue();
GeneResult geneResult = new GeneResult(mgiId, symbol,
hrMean.doubleValue(), lrMean.doubleValue(),
pValue.doubleValue());
// add to liststore
geneList.add(geneResult);
}
ColumnModel cm = new ColumnModel(configs);
// Now create our Grid and Dialog to display it in
Grid<GeneResult> geneGrid = new Grid<GeneResult>(geneList, cm);
geneGrid.setStyleAttribute ("borderTop", "none");
geneGrid.setBorders(true);
geneGrid.setStripeRows(true);
Dialog d = new Dialog();
d.setHideOnButtonClick(true);
d.setButtons(Dialog.CLOSE);
d.setBodyBorder(false);
d.setHeading("Genes for Chromosome " + chromosome +
" range " + range);
d.setButtonAlign(HorizontalAlignment.CENTER);
d.setLayout(new FitLayout());
d.setSize(500, 300);
d.add(geneGrid);
d.show();