Forum: wxRuby How to make a Grid reread the number of rows in a Table?

Posted by Svend Haugaard Sørensen (Guest)
on 2009-12-05 20:00
(Received via mailing list)
I have used GridTableBase to make and display a Table using a Grid.

But if I add a new row to the Table the Grid will not display a new row.

So if I start with 9 rows in the table and add a row, so there is
10 rows in the table. But the Grid will only display 9 rows.

Is seems like the Grid don't reread the the numbers of rows from
the Table.

How can I force the Grid to reread the number of rows?
Posted by Alex Fenton (Guest)
on 2009-12-06 06:14
(Received via mailing list)
Svend Haugaard Sørensen wrote:
> How can I force the Grid to reread the number of rows?
grid.refresh(), I think

alex
Posted by Svend Haugaard Sørensen (Guest)
on 2009-12-06 16:52
(Received via mailing list)
On Sun, 06 Dec 2009 05:14:06 +0000
Alex Fenton <alex@pressure.to> wrote:

> > the Table.
> >  
> > How can I force the Grid to reread the number of rows?
> 
> grid.refresh(), I think

grid.refresh and grid.force_refresh only update the data in the cells
but not the number of rows.
Posted by Svend Haugaard Sørensen (Guest)
on 2009-12-11 22:11
(Received via mailing list)
On Sun, 6 Dec 2009 16:50:12 +0100
Svend Haugaard Sørensen <shs@demosophia.net> wrote:

> On Sun, 06 Dec 2009 05:14:06 +0000
> Alex Fenton <alex@pressure.to> wrote:
> 
> > Svend Haugaard Sørensen wrote:
> > > I have used GridTableBase to make and display a Table using a
> > > Grid.
> > >
> > > But if I add a new row to the Table the Grid will not display a
> > > new row.

Okay I solved it by dropping the table and making a subclass of Grid.
And then using 'append_rows' and 'delete_rows' from the Grid class.

It seems like 'set_table' in Grid makes a clone of the table, and
thereby make it impossible to manipulate the table directly.

Thanks for the help.
Posted by Chloro Form (tony44)
on 2010-02-23 16:27
> Okay I solved it by dropping the table and making a subclass of Grid.
> And then using 'append_rows' and 'delete_rows' from the Grid class.
> 
> It seems like 'set_table' in Grid makes a clone of the table, and
> thereby make it impossible to manipulate the table directly.

Can anyone confirm this is the way to go?
Posted by Chloro Form (tony44)
on 2010-02-24 20:32
Tony Meier wrote:

> Can anyone confirm this is the way to go?

Answering my own question - yes, that seems to do the trick. When the 
underlying data changes, simply create a new table (a subclass of 
GridTableBase to be exact) and call mygrid.set_table again. Voila.
Posted by Alex Fenton (Guest)
on 2010-02-24 21:38
(Received via mailing list)
On 23/02/2010 15:27, Tony Meier wrote:
>> It seems like 'set_table' in Grid makes a clone of the table, and
>> thereby make it impossible to manipulate the table directly.
>>      
> Can anyone confirm this is the way to go?
>    
Yes, definitely. I looked at wxWidgets underlying C++ code for this a
while back. It clones the C++ object, so it's likely the Ruby Grid class
will continue to have this behaviour.

a
Posted by Alex Fenton (Guest)
on 2010-02-24 21:44
(Received via mailing list)
On 23/02/2010 15:27, Tony Meier wrote:
>> It seems like 'set_table' in Grid makes a clone of the table, and
>> thereby make it impossible to manipulate the table directly.
>>      
> Can anyone confirm this is the way to go?
>    
Yes, definitely. I looked at wxWidgets underlying C++ code for this a
while back. It clones the C++ object, so it's likely the Ruby Grid class
will continue to have this behaviour.

a
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.