gwt text column code not running Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of gwt text column code not running without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m building a Datagrid that contains recipe data contained in a “Recipes” object. Using TextColumns to fill out the table, but the code where I’m actually creating the columns doesn’t seem to run:

Window.alert("recipes: " + recipeList.get(0).getIngredients());

TextColumn<Recipes> ingredientColumn = new TextColumn<Recipes>() 
{   
    @Override
    public String getValue(Recipes ingredient) {
        return ingredient.getIngredient();
    }
};
Window.alert("after column creation");
ingredientColumn.setDataStoreName("Ingredients");
colList.add(ingredientColumn);

for (TextColumn col : colList) {
   this.table.addColumn(col, "header");
}

The alerts before and after the TextColumn block run (as does any subsequent code), and the data is there and is accurate. The Datagrid itself was instantiated with the Recipes object, so there isn’t any inconsistency there.

Also, I use the dataStoreName to set the column header, and the header actually does appear when I run my code, so the table itself seems to exist, just without the columns. I’ve tried putting an alert inside the TextColumn block and that never appeared, so the entire block seems to be getting bypassed.

I’m not sure if/how much more info might be needed to better assist potential answers as I’m quite new to GWT, but should edits be required, I’ll be glad to provide whatever info I can to get an accurate answer to my dilemma.

Thanks in advance!

Answer

There are a few key things to ensure when setting up a DataGrid:

  • columns are setup and added via addColumn calls
  • data is applied to the grid either by calling setRowCount()/setRowData() or via a data provider
  • the grid has sufficient height to display at least some rows
We are here to answer your question about gwt text column code not running - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji