"Randall" <[EMAIL PROTECTED]> writes:

> Here is the diff for a slight alteration to datagrid.kid that makes the
> first column data a link to the full data description.  I'm new to kid
> so I'd like to know if there is a better way to do what I've done.  I
> was looking for if/else, but it appears there is no else.  Also I tried
> a replace with the span, but couldn't get that to work.

I'd rather have it user-definable because it is not uncommon to have
"irrelevant" information on the first column (such as dates, for example) and
this might lead to a different expectation from the user (e.g. seeing all
transactions done in a given date instead of details of the current
transaction).

I'll change your code here so that you can see how py:replace works:

> Randall
>
> Index: turbogears/fastdata/templates/datagrid.kid
> ===================================================================
> --- turbogears/fastdata/templates/datagrid.kid  (revision 694)
> +++ turbogears/fastdata/templates/datagrid.kid  (working copy)
> @@ -23,7 +23,10 @@
>          </a>
>        </td>
>        <td py:for="col in columns">
> -        ${col.get_field(row)}
> +        <a py:if="col == columns[0]" href="${std.url(str(row.id))}">
> +          ${col.get_field(row)}
> +        </a>

        <a py:if="col == columns[0]" href="${std.url(str(row.id))}" 
py:replace="col.get_field(row)">
          this will be replaced in column zero
        </a>

> +        <span py:if="col != columns[0]">${col.get_field(row)}</span>

        <span py:if="col != columns[0]" py:replace="col.get_field(row)">
          this will be replaced in all other columns
        </span>

>        </td>
>      </tr>
>    </table>
>

-- 
Jorge Godoy      <[EMAIL PROTECTED]>

Reply via email to