You should be able to implement your first idea by extending the table
tag.
<extend tag="table">
  <old-table merge>
    <tr:>
            <if test="&fields">
              <with-fields merge-attrs="&all_attributes & attrs_for
(:with_fields)" force-all>
                <td param="#{this_field.to_s.sub('?', '').gsub('.',
'-')}-view" class="#{'numeric-field' if this.is_a?
(Numeric)}"><call-tag tag="&field_tag"/></td>
              </with-fields>
              <td class="controls" param="controls" if="&all_parameters
[:controls]">
                <a param="edit-link" action="edit"
if="&can_edit?">Edit</a>
                <delete-button param/>
              </td>
            </if>
    ...

Unfortunately you have to override the whole row since you won't know
what the field name is to be able to target just the <td> tags.

Or you could override the view for that type and add a class to it.

If it's a one of a kind deal it's probably cleaner to just give the
specific fields the class like you did.

On Jun 9, 12:14 am, Montgomery Kosma <[email protected]> wrote:
> to clarify my last point on right alignment ... I can obviously do
> this in application.css:
>
> td.size-megabytes-view,
> td.size-items-view {
>     text-align: right;
>
> }
>
> but then I though, shouldn't we leverage the model's knowledge of data
> types to avoid specifying every numeric column explicitly in css?
>
> One approach is to tweak the call to call-tag in def tag="table" in
> rapid-core.dryml:
>
>                 <td param="#{this_field.to_s.sub('?', '').gsub('.',
> '-')}-view"><call-tag tag="&field_tag"/></td>
>
> by adding something like  <%= class="numeric-field" if this.is_a?
> (Numeric) %>.  However, my kung fu is too weak, I couldn't make this
> work.  Anyway, given my overrides to use number_with_delimiter and
> number_with_human_size, I'm skipping over the default call to call-tag
> anyway.
>
> So, the best solution I've devised is to add a class="numeric-field"
> argument to the dryml tags for each numeric field, as shown here.  At
> least that keeps the model out of my css.  Love to hear of any
> alternative ideas!
>
> <index-page>
>   <collection: replace>
>     <table-plus fields="this, custodian, data_type, origin, date_from,
> date_to, size_megabytes, size_items">
>       <empty-message:>No file sets have been created.</empty-message:>
>       <size_megabytes-heading-link:>Volume</size_megabytes-heading-
> link:>
>       <size_megabytes-view: class="numeric-field"><%=
> number_to_human_size(this*1024*1024) %></size_megabytes-view:>
>       <size_items-heading-link:>Items</size_items-heading-link:>
>       <size_items-view: class="numeric-field"><%= number_with_delimiter
> (this) %></size_items-view:>
>     </table-plus>
>   </collection:>
> </index-page>
>
> On Jun 9, 12:53 am, Montgomery Kosma <[email protected]> wrote:
>
> > Throwing this out there to seed the google groups search engine, since
> > it would have helped me...
>
> > Using table-plus to implement my model's index page, I wanted to
> > change the label above two of my columns.
>
> > This is super-easy - table-plus offers a "xxx-heading-link" tag to do
> > just this, where xxx is the column name.  The only trick was figuring
> > out the not-really-documented distinction between xxx-heading-link and
> > xxx-heading.
>
> > To illustrate, here's the index.dryml for my FileSet model:
>
> > <index-page>
> >   <collection: replace>
> >     <table-plus fields="this, custodian, data_type, origin, date_from,
> > date_to, size_megabytes, size_items">
> >       <empty-message:>No file sets have been created.</empty-message:>
> >       <size_megabytes-heading-link:>Volume</size_megabytes-heading-
> > link:>
> >       <size_megabytes-view:><%= number_to_human_size(this*1024*1024)
> > %></size_megabytes-view:>
> >       <size_items-heading:>Items</size_items-heading:>
> >       <size_items-view:><%= number_with_delimiter(this) %></size_items-
> > view:>
> >     </table-plus>
> >   </collection:>
> > </index-page>
>
> > Above, <size_megabytes-heading-link:> shows the "right" way to
> > override the column heading, as (despite its name) it doesn't mess
> > with the link, just the text of the heading.  Note however,
> > <size_items-heading:> shows the "wrong" way to change the heading, as
> > (despite its name) it changes the entire heading, meaning that it
> > eliminates the click-to-sort link and the sort indicator arrows, in
> > addition to the default heading text.
>
> > (Illustration on calling rails number helpers included, at no extra
> > charge!)
>
> > Share & Enjoy.
>
> > (Now, to figure out a DRY way to make all my numeric columns right
> > align...)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" 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/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to