Herb schrieb:
> Hi folks,
> I am trying to put a datagrid inside a form. I want users to be able
> to put user name and email address in the grid and then submit these
> data for processing. I cannot seem to get the structure quite right
> to do this.
>
> from tw.forms import TableForm, PasswordField, TextField, DataGrid,
> datagrid
> from tw.api import WidgetsList
> from marchive.model.auth import User
>
> class CusGridForm(TableForm):
> action = 'addCustodians'
> class fields(WidgetsList):
> cusgrid = DataGrid(fields = [("Name", "user_name"), ("Email
> Address", "email_address")])
>
> The code above won't display the grid, but it does show a submit
> button. There is nothing to show that the DataGrid is being
> instantiated inside the form, when the form is instantiated.
>
> I can display a table with one row:
>
> from tw.forms import TableForm, PasswordField, TextField, DataGrid,
> datagrid
> from tw.api import WidgetsList
> from marchive.model.auth import User
>
> class CusGridForm(DataGrid):
> fields = [("Name", "user_name"), ("Email Address",
> "email_address")]
> default = [User()]
>
> I suppose I could add my own form and submit button, etc., but still,
> I don't know how to add rows to this table when it is displayed. I
> would like to have a button to add another row, and let the user enter
> a new name and email address. How do I make the rows editable?
> Finally, the user should be able to submit the whole thing.
>
> I'm using TG2 in a virtual environment.
> I suppose that I could go to the YUI datagrid and build it with ajax.
> I've done that before, but I did not want to add the overhead that
> that would take.
>
> Any thoughts / suggestions?
The problem is that tw.forms won't display things that aren't subclasses
of tw.forms.FormField.
So you *might* be lucky just creating a subclass of DataGrid & FormField.
If that doesn't work, using your own template copy of the Form in
question & putting an explicit ${children.datagrid.display()} will
certainly work.
Diez
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---