Sorry about the vague subject line. And also I apologise for the
rambling nature of this; I'm trying various approaches and not getting
very far, so I'll just talk about what I want and what I've done and
see what people have to say.
I have a table of data, where I want the end user to be able to edit a
field in a particular one of the columns. A good example would be a
shopping cart with a quantity field for each item in the cart. So it's
a cross between a form and a grid of data, basically. And it would be
handy to be able to edit that data without reloading the page.
Now, I could do it the long way - wrap it all in <form> tags, put the
quantity output into an edit box each time, inject unique IDs built up
from some string plus the id of the item in question, add an 'amend'
button somewhere which submits to a separate page, and have that
separate page do something with the form inputs. I am not sure I'd
know how to handle this last case, since the typical TG form handling
works best with fixed inputs. Would I use **args or something and
iterate through them?
I tried using SingleSelectField widgets to give the user a handy drop-
down to use. Unfortunately this seemed to complicate matters:
- how would I inject a unique 'id' parameter into it, based on the
current object in the view? I tried passing "attrs={'id':'row_$
{row.id}'}" into the widget call in the template, but the template
parser either can't handle dictionaries in there, or doesn't like
recursively expanding values, or both. I suppose I could pre-create
the parameterised widget instances in the controller and package them
up with the rows in a tuple that I pass to the view, but that sort of
thing could get brittle quite quickly.
- if I wanted the use of that field to trigger a Javascript call, so
that I could submit the value via AJAX, how would I go about that? Is
that even possible with a SingleSelectField widget or would I have to
write my own based on that? Are there any docs on writing Widgets?
Similarly, if I chose to use an edit box instead of the
SingleSelectField widget, what would be a simple way of doing this,
allowing the user to type a value, hit enter, and have just that field
submitted in the background? It's safe to assume I'll use Mochikit for
the request - I'm just a bit vague on how to identify the field it's
come from, and match that up to the appropriate object in the Model.
I'm sure much of this is trivial web dev stuff, but it's been a while
since I did any in earnest so I'm having trouble remembering the usual
tricks.
--
Ben Sizer
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---