Ignacio,
thank you very much; that does indeed work. BTW, it also got me to get more
accommodated to to using replacements, and with some tweaking, I got a
successful table-plus, even with sorting on the virtual fields.
However, also in your example, the inputs are all in a single table cell.
I did manage to create a tabular layout with the input fields dispersed
over several cells, but this uses <div>s and <span>s with "display:
table-cell" etc. It seems that browsers do not like mixing <tr>/<td> and
"display: table-row"/"display: table-cell", neither in a <table> nor
"display: table". Neither do they like <form>s spanning outside the <tr>
nor covering any number of <td>s (in Firefox, this results in the </form>
being contracted to right after the <form …>, causing the <input>s to be
lost from the <from> context).
So, I'll probably end up making my own copies of Hobo's <table> and
<table-plus> converted to the "display: …" forms…
-Marcel
Am Donnerstag, 1. August 2013 19:10:29 UTC+2 schrieb Ignacio Huerta:
>
> Hi Marcel,
>
> I think there is an easy way to do this by replacing the tr completely.
> This way you can create a new "tr" with the correct part name:
>
> <index-page>
> <collection: replace>
> <data-table/>
> </collection:>
> </index-page>
>
> <def tag="data-table">
> <table-plus without-page-nav without-header fields="this, sum_x,
> sum_y, add_x, add_y, actions">
> <tr: replace>
> <tr part="row">
> <td><a/></td>
> <td><view:sum_x/></td>
> <td><view:sum_y/></td>
> <td>
> <form:datapoints.new ajax refocus-form>
> <input:x/>
> <input:y/>
> <submit label="Add"/>
> </form>
> </td>
> </tr>
> </tr:>
> </table-plus>
> </def>
>
>
> I tested this locally, so it should work ;)
>
> Regards,
> Ignacio
>
>
>
> El 01/08/13 12:46, Marcel Waldvogel escribi�:
> > Hi, I'm fighting with Ajax forms in a table.
> >
> > The goal of the application is to have multiple named sets of data
> > points, one set per row, where new data points may be entered in the
> > same row:
> >
> > Dataset name | Sum X | Sum Y | Add X | Add Y |
> > --------------+-------+-------+---------+---------+--------
> > Measurement 1 | 100 | 200 | [Input] | [Input] | [Submit]
> > Measurement 2 | 120 | 220 | [Input] | [Input] | [Submit]
> >
> > In the end, I would like to use a sortable table, but I'm starting
> small.
> >
> > Datapoint has x and y fields (floats) and belongs_to :dataset.
> > Dataset has a title field (string) and sum_x, sum_y methods, which sum
> > the datapoints (avoiding the nil pitfalls created by
> > <form:datapoints.new> :-)).
> >
> > It works when I use the card format with minimal markup:
> >
> > <def tag="card" for="Dataset">
> > <card class="dataset" param="default" merge>
> > <header: param>
> > <a><name/></a> | <do part="dataset"><view:sum_x/> | <view:sum_y/> |
> > <form:datapoints.new ajax
> > refocus-form><input:x/><input:y/><submit label="Add"/></form></do>
> > </header:>
> > <body: param/>
> > </card>
> > </def>
> >
> > However, I have been unable to put this in a table. The plan was to have
> > the <tr> as the part, wrapping a <form> which in turn wraps the <td>s
> > with one <view> or <input> each. The problems are as follows:
> >
> > * Setting a "part=" attribute on <tr> results in "undefined method
> > `all_parameters' for #<#<Class:0x007fdf214ab958>:0x007fdf214b3888>"
> > * Wrapping the naked <tr> in <do part="foo"> has the same problem
> > * Having the form span the <td>s results in an OK-looking page, but
> > when submitting the Ajax form, it results in "Couldn't create the
> > Datapoint. X can't be blank, Y can't be blank"
> >
> > The closest thing to working is this (modelled after <table> tag):
> >
> > * The entire <form> is in one <td>, defeating the <table> layout.
> > * The sums are not updated by Ajax, only by a manual refresh.
> > * Even when changing the sum_y view to <view part="sum-x"
> > id="sum-x-#{scope.dataset.typed_id}"/> and adding an explicit
> > 'update="sum-x-#{scope.dataset.typed_id}"' or 'updates="#sum-x-�"'
> > to the <form>, no update happens.
> >
> > What am I doing wrong?
> > -Marcel
> >
> > <datapoints-table with="&Datapoints.all">
> > <title-view:><a with="&this_parent"><view:title/></a></title-view:>
> > </datapoints-table>
> >
> > <def tag="datapoints-table">
> > <unless test="&(this.nil? || this.empty?) && !empty">
> > <table class="datapoints-table">
> > <thead>
> > <tr><th>Dataset name</th><th>Sum X</th><th>Sum Y</th><th>Add
> > X</th><th>Add Y</th></tr>
> > </thead>
> > <tbody>
> > <tr repeat>
> > <set-scoped dataset="&this">
> > <do with="&scope.dataset">
> > <with-fields fields="title, sum_x, sum_y">
> > <td param="#{scope.field_name.to_s.sub('?', '').gsub('.',
> > '-')}-view"><view/></td>
> > </with-fields>
> > </do>
> > <td param="datapoint-input">
> > <form:records.new ajax refocus-form>
> > <input:x/>
> > <input:y/>
> > <submit label="Add"/>
> > </form>
> > </td>
> > </set-scoped>
> > </tr>
> > </tbody>
> > </table>
> > </unless>
> > </def>
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Hobo Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to [email protected] <javascript:>.
> > To post to this group, send email to [email protected]<javascript:>.
>
> > Visit this group at http://groups.google.com/group/hobousers.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
> --
> Ignacio Huerta Arteche
> http://www.ihuerta.net
> Tel�fono: 0034 645 70 77 35
> Email realizado con software libre
>
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/groups/opt_out.