wxRuby - tabular data with extra widgets

Hi,

I sent this to the ruby-talk list, but didn't get any response, so

I’m trying again here. Hopefully it’s more appropriate!

I am needing to display a table of data.
I need to be able to sort the columns by clicking the label at the

top (ideally such that one click sorts ascending, the next descending
etc etc)
I need grid lines.
I need to be able to include drop down lists in multiple columns,
such that selecting the drop down will change columns in the same row.

This data is backed by active record, and I have active support etc

available.

My first thought was to use Wx::Grid, but I don't have the first

idea how to go about getting a drop down into a column.

My second thought is to use a grid sizer of some sort, but that

would mean creating my own buttons for the column headers, doing
something to get a grid etc etc.

What other options to I have? Or how do I go about 1)?

All pointers appreciated!

Current source is at

http://codaset.com/nevynxxx/wxrcg/source/master/blob/lib/views/dm_screen_frame.rb

Regards

Anthony

Anthony M. wrote:

I sent this to the ruby-talk list, but didn't get any response, so

I’m trying again here. Hopefully it’s more appropriate!

Welcome - it certainly is appropriate here.

My first thought was to use Wx::Grid, but I don't have the first

idea how to go about getting a drop down into a column.

It sounds like Wx::Grid is definitely the one you want to use.

To put drop-downs in cells, use Wx::GridCellChoiceEditor.
GridCellEditors change the interface that is used to edit the contents
of a Grid cell. You can also use and define custom renderers for the
non-editing display of a cell, either by using one of the predefined
subclasses of GridCellRenderer, or by defining your own completely
custom presentation.

There are event hooks for a wide variety of things including cell value
changes.

If the data source for the grid is an RDBMS possibly via an ORM like
ActiveRecord, you can also use GridTableBase to make the link between
the model and the GUI view neat to program.

Take a look at the samples supplied with wxruby; in the folder ‘grid’
you should find all of the above exemplified. And please feel free to
come back for further help - the Grid is a powerful but also pretty
complex class.

cheers
alex

Alex F. wrote:

It sounds like Wx::Grid is definitely the one you want to use.

To put drop-downs in cells, use Wx::GridCellChoiceEditor.
GridCellEditors change the interface that is used to edit the contents
of a Grid cell. You can also use and define custom renderers for the
non-editing display of a cell, either by using one of the predefined
subclasses of GridCellRenderer, or by defining your own completely
custom presentation.

Cool, I’ll have a look into that…

There are event hooks for a wide variety of things including cell
value changes.

If the data source for the grid is an RDBMS possibly via an ORM like
ActiveRecord, you can also use GridTableBase to make the link between
the model and the GUI view neat to program.

It is indeed, so I’ll have a look at this too…

Take a look at the samples supplied with wxruby; in the folder ‘grid’
you should find all of the above exemplified. And please feel free to
come back for further help - the Grid is a powerful but also pretty
complex class.

cheers
alex
Thanks Alex, much appreciated. I’m sure I’ll be back :slight_smile:

Anthony