[fxruby-users] Updating rows in a table

Martin Hawkins martin.hawkins at gmail.com
Thu Aug 20 12:18:23 EDT 2009

Many thanks for the suggestion. The idea of adding a 'cancel all
changes option' is an interesting one and the commit at the end of all
of all the changes would certainly make coding easier and neater and
response times shorter as the tables grow.

On Aug 20, 10:54 am, "Philippe Lang" <philippe.l... at attiksystem.ch>
> Hi Martin,
> I'm not sure it's the best idea to update your data while the user is working with the GUI. I think you have better let the user fill and change your table, and commit all the changes at the end, by comparing the activerecord content, and your table content. This way, you get an extra feature as well: the ability the CANCEL all the changes made to the table.
> When doing the comparison, you basically have to do 3 different things:
> 1) Detect that a line was deleted in the table, and delete the record properly.
> 2) Detect that a line was inserted in the table, and insert the record properly.
> 3) Detect tha a line was update in the table (one or more columns), and update the record properly.
> I suggest you use in the table a column that stores your record id. You can make it invisible if you want.
> This is how we do it inhttp://www.attiksystem.ch/beerp/beerp-the-fxruby-erp/. It works just fine.
> Good luck!
> Philippe Lang
> Attik System
>   _____  
> De : fxruby-users-boun... at rubyforge.org [mailto:fxruby-users-boun... at rubyforge.org] De la part de Martin Hawkins
> Envoyé : jeudi, 20. août 2009 11:18
> À : fxruby-us... at rubyforge.org
> Objet : [fxruby-users] Updating rows in a table
> I'm new to using fxruby, so please excuse any daft questions.
> 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:
> def initialize(app)
>   super(app, "Library", :width => 600, :height => 400)
>   @authors = Author.find(:all)
>   table = FXTable.new(self, :opts => LAYOUT_FILL|TABLE_COL_SIZABLE)
>   table.setTableSize(@authors.length, 2)
>   table.rowHeaderMode = LAYOUT_FIX_WIDTH
>   table.rowHeaderWidth = 0
>   table.setColumnText( 0, "Last Name")
>   table.setColumnText( 1, "First Name")
>   r, c = 0, 0
>   @authors.each do |author|
>    table.setItemText(r, c, author.author_last_name)
>    table.setItemJustify(r, c, FXTableItem::LEFT)
>    table.setItemText(r, c + 1, author.author_first_name)
>    table.setItemJustify(r, c + 1, FXTableItem::LEFT)
>    r += 1
>   end
> end
> 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 presume that I'm supposed to use FXDataTarget - but I'm really not sure how.
> I haven't even started looking at add and delete.
> Any pointers would be greatly appreciated.
> Martin
> _______________________________________________
> fxruby-users mailing list
> fxruby-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/fxruby-users

More information about the fxruby-users mailing list