PDA

View Full Version : When placing Grid in Dialog, rows are not showing



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();

sven
9 Aug 2010, 10:57 AM
Can you plesae post some small testcase that implements EntryPoint and so is runnable for us?

obwalton
10 Aug 2010, 3:34 AM
While preparing a working example to post, it was discovered that I was processing an Integer, when my data contained a Double in my two formatters. The class cast exception somehow slipped through without being seen. The hazards of cutting and pasting code from another location.

Maybe a new question would be, other than wrapping every piece of code that processes numeric data with a try catch to make sure the value is of the correct type, with GWT/GXT/Netbeans how does one make sure all of the client side errors/exceptions are visible?

Thanks, and sorry for wasting anyone's time.

Dave

sven
10 Aug 2010, 3:38 AM
I run the code in development mode and i can see all the exceptions without any problems.