Flex Table - Remove rows

264 views
Skip to first unread message

Jonas

unread,
Nov 12, 2009, 9:06:48 PM11/12/09
to Google Web Toolkit
Hello all,

i'm trying to remove the rows from a dynamic flex table, but without
success. This is my code, i have 5 columns and a variable number of
rows. The idea is to remove all the rows and put new rows in it.

Here is what i'm doing

for (int i = 0; i < __this.getRowCount(); i++) {
__this.removeRow(i);
__this.getFlexCellFormatter().setRowSpan(0, 0, i);
__this.getFlexCellFormatter().setRowSpan(0, 1, i);
__this.getFlexCellFormatter().setRowSpan(0, 2, i);
__this.getFlexCellFormatter().setRowSpan(0, 3, i);
__this.getFlexCellFormatter().setRowSpan(0, 4, i);
}

I think my problem is in the HTML manipulation, if somebody could help
i would be very gratefull

Thanks in advance

Best Regards

João Lopes

Paul Robinson

unread,
Nov 13, 2009, 4:59:32 AM11/13/09
to google-we...@googlegroups.com
After you remove row number 0, what was row 1 becomes the new row 0 etc
because everything shifts up one row.

The way you've set up your loop, what starts off as row 1 will never be
removed - second time through the loop you remove row 1, but that is the
row that started off as row 2. Also, don't forget that each time through
the loop getRowCount() will return a different value.

Setting the row span looks odd too. You remove row i, then set the row
span for row i (which was row i+1 before you removed row i).

You could try this:
for (int i=0, n=__this.getRowCount() ; i<n ; i++)
__this.removeRow(0);

or this:
__this.removeAllRows();

HTH
Paul
> Jo�o Lopes
>
>
>
>

Jonas

unread,
Nov 13, 2009, 6:08:51 AM11/13/09
to Google Web Toolkit
Thank you so much Paul, it worked 5 star.

Best regards

João Lopes
> > Jo�o Lopes

Jonas

unread,
Nov 13, 2009, 6:09:47 AM11/13/09
to Google Web Toolkit
Thank you so much Paul, it worked 5 stars.

Best Regards

João Lopes

On 13 Nov, 09:59, Paul Robinson <ukcue...@gmail.com> wrote:
> > Jo�o Lopes

rjcarr

unread,
Nov 14, 2009, 3:53:47 PM11/14/09
to Google Web Toolkit
I tend to do this to clear out tables:

while(table.getRowCount() > 0) {
table.removeRow(0);

Zak

unread,
Nov 15, 2009, 12:30:39 PM11/15/09
to Google Web Toolkit
I do the same as rjcarr

It's also really convenient if you have a header row (with the names
of the columns, for example). then to clear the data you can do:

while (table.getRowCount() > 1)
table.removeRow(1);

it's too bad FlexTable#clear() only removes the widgets... it's never
been useful enough to use for me :P
Reply all
Reply to author
Forward
0 new messages