views:

825

answers:

3

I am looking for a way to edit data and have values dynamically calculated (i.e. totals, averages, etc.) My application is a web based gradebook system for teachers and one of the big challenges is allowing them to enter/update grades. The most natural solution for this type of data is a table or spreadsheet grid and my first thought was to write something myself, but I quickly got over that idea. :)

The chief problem I'm having is being able to calculate things in real time. When a teacher changes a grade I need the table to update that students AVG % and possibly their letter grade. It doesn't have to feed these calculations back to the server (they are just for show) but the cell changes do have to be saved (via AJAX).

I know this should probably be a FAQ and I found these two answers (1, 2) but my requirements are a bit different (I think). First of all I'm looking for something that integrates with RoR fairly well; this means using Prototype. It should also be pretty lightweight and clean; I don't need fancy things like pictures, sub-groups, etc. Lastly, since my project is under the GPL, it must be open source.

Any hints? Right now I'm looking at TableKit & Rico LiveGrid but I'm not sure they can do the row & column calculations that I need.

+1  A: 

I think ExtJS has something like this. It'd be worth while checking it out: http://extjs.com/

Ryan Bigg
Thank you for the tip, but it looks like ExtJS is a rather large framework. I wonder if it can be striped down to just one or two components...
RNHurt
A: 

Saving it in the database might be easiest. Calculate and save the things you need, then update the view.

I'm not sure how your UI works, but you can attach an AJAX event to the UI where they enter the information, saving the data. The controller can respond to javascript, dropping into an RJS template that would update the values you need on the page.

Kevin Davis
Yes, I thought about writing back to the DB but the grades are entered as fast as possible and I'm afraid that beating up my server with thousands of little hits and repainting my table would not be conducive to a good user experience. :)Thanks for the idea though.
RNHurt
A: 

After searching for something lightweight and easy to use I have given up and am writing my own little bits of JavaScript to do my bidding for me. Its not perfect but it seems to work pretty well, and it satisfies my needs (for now).

RNHurt