Topic: ROR spreadsheet

Hey everyone.

Im attempting to create essentually what will be an openoffice spreadsheet using ajax_scaffold.

Now by default each line will be non-editable and will have actions to edit or delete.  No problems there.

The last action will be "add a line below" which will add a line below the one clicked obviously .

Now the problem I have:

Each line is numbered.  1..x and adding a line will obviously change all the line numbers below it.

so do you guys have any suggestions as to how I could possible do this?

what techniques would you use?

would you have a client side javascript function that that you call in your ajax?  or would you regenerate the page? what other ideas do you have?

Re: ROR spreadsheet

I'd probably develop a function that takes a row number as an argument and moves all the values of all the rows below it down one row - possibly adding an additional row at the bottom - and inserting the new line at the right spot.

I'd do it client side because folks are just so used to spreadsheets responding quickly.  It probably wouldn't be any tougher to do it via javascript than in back-end ruby.

Re: ROR spreadsheet


ill try to explain in a little more detail what I was hoping to do.

clicking on the add below button would...

ajax to :controller => blah, :action => add_line  which would create and save the line in the db and change other db model items to reflect this (ie line numbers).  then js returned which calls.

add_row(id, scaffold, other, other, etc,etc).

that adds row and calls update_rows_below(id)

or at least something similar.  creating a row on a sheet must be verified by the server as the columns have names and the row is categoried.

Re: ROR spreadsheet

Maybe put a "position" column in the rows table and use the "acts_as_list" method in the Row module? I think rails will auto-update the position upon inserting and deleting rows.

Although, if you do this all client side - which I agree is a good idea for fast response - then the "acts_as_list" helper method wouldn't help much because JavaScript would have to handle it all.

Railscasts - Free Ruby on Rails Screencasts