[fxruby-users] Updating rows in a table

Martin Hawkins martin.hawkins at gmail.com
Thu Aug 20 11:34:55 EDT 2009

Thanks for the reply.
It's about keeping the SQL table and the FX table in sync.
My sql table is sorted by last name and the table ids don't match up
with the row numbers in the fx_table. I've created a column which is 0
wide that contains the sql_id so that when I identify the item that's
been modified (using the row and column information from SEL_REPLACED,
as you suggest), I know which SQL table row to update.
I then pull back the data from the SQL table so that the edited name
is in the correct position and re-draw the table.
The edited name is then highlighted using makPositionVisible and

I saw FXDataTarget and was hoping that the rather clunky code I've got
could be made a lot neater by using it, rather like cocoa bindings I
suppose. I see that FXDataTarget can't be used with an Array so guess
I'm stuck with my sledgehammer approach.

On Aug 20, 3:16 pm, Lyle Johnson <l... at lylejohnson.name> wrote:
> On Thu, Aug 20, 2009 at 4:18 AM, Martin Hawkins<martin.hawk... at gmail.com> wrote:
> > I'm loading data from a SQL table using activerecord and displaying it in a
> > table. At the moment I'm iterating through the table,so the code is as
> > follows:
> <snip>
> > I want to be able to edit, add and delete. Using SEL_REPLACED I can detect
> > when a cell has been edited and so can update the record based on row and
> > column position. This is not good enough as the SQL table entries are not necessarily
> > unique.
> I don't understand what the fact that SQL table entries aren't
> necessarily unique has to do with it. When a table cell is edited, the
> table sends a SEL_REPLACED message to its target, and the message data
> is an FXTableRange instance indicating which cell(s) were modified. So
> you should be able to do something like this to determine which row
> and column was edited:
>     table.connect(SEL_REPLACED) do |sender, sel, table_range|
>       puts "finished editing the cell at row=#{fm.row}, col=#{fm.col}"
>     end
> Hope this helps,
> Lyle
> _______________________________________________
> fxruby-users mailing list
> fxruby-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/fxruby-users

More information about the fxruby-users mailing list