[PHPTAL] Table column with difference value
Krzysztof Zaleski
cshyshtof at gmail.com
Wed Mar 26 22:04:57 CET 2008
I played with this solution quite a bit, and it seems it works fine only
with static tables. But, I use Iterator class to generate table entries and
I get the message "Can't to use Iterator class as an array" with entry data[
repeat.datarow.index-1][3]. Thanks anyway. Nice solution though.
2008/3/24, Krzysztof Sikorski <dreamer.pl at gmail.com>:
>
> I think I got the solution to your problem. Try this kind of template:
>
> <table>
> <tr tal:repeat="datarow data">
> <td tal:content="repeat/datarow/index">row number</td>
> <td tal:content="datarow/0">row[0]</td>
> <td tal:content="datarow/1">row[1]</td>
> <td tal:content="datarow/2">row[2]</td>
> <td tal:content="datarow/3">sum</td>
> <tal:block condition="repeat/datarow/start">
> <td>---</td>
> <td>---</td>
> </tal:block>
> <tal:block condition="not: repeat/datarow/start">
> <td tal:content="php: data[repeat.datarow.index-1][3]">prev_sum</td>
> <td tal:content="php: datarow[3] - data[repeat.datarow.index-1
> ][3]">delta</td>
> </tal:block>
> </tr>
> </table>
>
> I tried to write it in a self-explaining way.
>
> P.S.:I assumed the data from DB is in this form:
> $data = array(
> 0 => array('1','2','2','5'),
> 1 => array('3','4','5','12'),
> 2 => array('0','2','1','3'),
> );
> If I'm wrong, you should at least get the idea of the solution.
>
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL at lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>
--
Krzysztof Zaleski
CCNP, JNCIS
Tel.: +48 667 668 428
E-mail: cshychtof at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/phptal/attachments/20080326/bbdd15a9/attachment.htm
More information about the PHPTAL
mailing list