# wxRuby - tabular data with extra widgets

**URL:** <https://www.ruby-forum.com/t/wxruby-tabular-data-with-extra-widgets/178747>\
**Category:** wxRuby\
**Created:** [November 10, 2009, 5:57pm UTC](https://www.ruby-forum.com/t/wxruby-tabular-data-with-extra-widgets/178747 "2009-11-10T17:57:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![inertia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/d07c76/32.png) [@inertia](https://www.ruby-forum.com/u/inertia)\
**Post date:** [November 10, 2009, 5:57pm UTC](https://www.ruby-forum.com/t/wxruby-tabular-data-with-extra-widgets/178747/1 "2009-11-10T17:57:30Z")

</div>

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](http://codaset.com/nevynxxx/wxrcg/source/master/blob/lib/views/dm_screen_frame.rb)

Regards

Anthony

---

<div class="post-metadata">

**Author:** ![inertia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/d07c76/32.png) [@inertia](https://www.ruby-forum.com/u/inertia)\
**Post date:** [November 10, 2009, 6:23pm UTC](https://www.ruby-forum.com/t/wxruby-tabular-data-with-extra-widgets/178747/2 "2009-11-10T18:23:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![inertia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/d07c76/32.png) [@inertia](https://www.ruby-forum.com/u/inertia)\
**Post date:** [November 10, 2009, 10:32pm UTC](https://www.ruby-forum.com/t/wxruby-tabular-data-with-extra-widgets/178747/3 "2009-11-10T22:32:00Z")

</div>

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 🙂

Anthony
