Hi Pete,
If you know the number of rows and columns that your table will need and
don't expect it to change, then by all means use the Grid widget. The
FlexTable will create new rows dynamically for each row added via the
insertRow() method. The time to execute the method to insert the row may be
negligible, but the cost of adding more <tr> elements each time insertRow is
called can be expensive. Your users will also pay for new columns that are
added dynamically through the FlexTable. The Grid widget is instead a
ready-to-render table with the specified number of rows and columns
constructed in the table. If the number of rows and columns is less than,
say, 10. you may not notice any difference in performance. As you climb to
more rows and columns, however, the difference can be much greater.

You should only consider using the FlexTable if you really need to grow a
table dynamically. In all other cases, the Grid widget or your own HTMLTable
subclass with a predefined number of rows and columns would be best.

Regarding VerticalPanel / HorizontalPanel versus the Grid - it depends on
what you would like to place in said panels or widgets. If it's just text,
the Grid will be suitable, but you could also use panels (in fact, the test
code snippet below produces the very similar same HTML table structures for
both the grid and the panel implementation). If it's anything more than text
data (such as other widgets), it might be better to use a panel to have
better control over the positioning and layout of the contained widget. On
the other hand, you may not want to use either option of horizontal panels
or grids if you're adding widgets and instead prefer an HTMLPanel with a
FlowPanel (see Kelly Norton's presentation link below).

"Performance Tips for Google Web Toolkit" (starting at 23:00 - 27:00):
http://www.youtube.com/watch?v=q9hhENmVTWg

Grid vs Panels:

  public void onModuleLoad() {
    VerticalPanel mainPanel = new VerticalPanel();
    Grid grid = new Grid(5, 5);
    for (int i = 0; i < 5; i++) {
      for (int j = 0; j < 5; j++) {
        grid.setText(i, j, "bonjour");
      }
    }

    VerticalPanel verticalPanel = new VerticalPanel();
    for (int i = 0; i < 5; i++) {
      HorizontalPanel horizontalPanel = new HorizontalPanel();
      for (int j = 0; j < 5; j++) {
        horizontalPanel.add(new Label("hello"));
      }
      verticalPanel.add(horizontalPanel);
    }

    mainPanel.add(grid);
    mainPanel.add(verticalPanel);
    RootPanel.get().add(mainPanel);
  }

The HTML table structure for both the panels and the grid in the code
snippet below will almost be exactly the same.

Hope that helps,
-Sumit Chandel

On Wed, Jul 29, 2009 at 11:24 AM, [email protected] <[email protected]>wrote:

>
> If I know exactly how many rows and columns I need, is there any
> performance advantage to using the Grid widget over the FlexTable
> widget?
>
> Along the same lines, is there any advantage to using Grid over
> HorizontalPanel, or VerticalPanel?
>
>
> - - - - - - - - - - - - - - - - - - - -
> Pete Yorke
> Storke Brothers, LLC
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to