dlute
|
| Posted: 02/11/2005, 9:40 AM |
|
I am trying ti find out how to get 4 columns per row in a grid using CCS,
with PHP.
The examples I have seen so far do not tell you how to do this with PHP
Anyone have any ideas?
|
|
|
 |
dirksamson
Posts: 32
|
| Posted: 02/13/2005, 2:44 AM |
|
Quite easy; the basics are just to have <td> ...... </td> between the <!-- BEGIN Row --> and <!-- END Row --> tags and to insert something like "</tr><tr>" every once in a while. Here below the code I used:
1) HTML Template
===============
<table>
<tr><td colspan="{columns}">HEADER OF THE TABLE</td></tr>
<tr>
<!-- BEGIN Row -->
<!-- BEGIN RowError -->{Error}<!-- END RowError -->
<td class="DataTD"> TABLECELL {TIME}{EndRowLabel}
<!-- END Row -->
</tr>
</table>
2) BeforeShow event
=================
$columns = 8;
$Tpl->SetVar("columns", $columns);
2)
_________________
Dirk |
 |
 |
dirksamson
Posts: 32
|
| Posted: 02/13/2005, 2:48 AM |
|
(excuse me, pressed enter too quickly; disregard 2) in previous post)
2) BeforeShow event
================
global $columns;
$columns = 8;
$Tpl->SetVar("columns", $columns);
3) BeforeShowRow event
====================
//create table rows manually
$row = $GRID->ds->Row;
$maxrow = $GRID->ds->RecordsCount;
$col = $row % $columns; //column number, starts at 1, 0 is the last one
if($row == $maxrow) {
$emptystring = "";
//create empty td's if needed.
if($row % $columns != 0) {
$empty = $columns - $col;
} else $empty = 0;
while($empty > 0) {
$emptystring .= "\n".'<td class="DataTD" align="center"> </td>';
$empty--;
}
$GRID->EndRowLabel->setValue($emptystring);
} else {
//if row number is 4,8,12,etc start new row
if($col == 0) $GRID->EndRowLabel->setValue("\n</tr><tr>");
else $GRID->EndRowLabel->setValue("");
}
NB: GRID should -of course- be replaced with the name of the grid you are using.
Feedback is always welcome!
Succes, Dirk
_________________
Dirk |
 |
 |
dlute
|
| Posted: 02/16/2005, 12:04 PM |
|
Thank you for the help. I don't do much custom coding so I must be missing something.........
I get this error:
Fatal error: Call to a member function on a non-object
on the line with this:
$Tpl->SetVar("columns", $columns);
|
|
|
 |
Nicole
Posts: 586
|
| Posted: 02/17/2005, 2:38 AM |
|
Hello,
You have forgotten to declare $Tpl as global variable before using it. Please try
global $Tpl;
$Tpl->SetVar("columns", $columns);
...
_________________
Regards,
Nicole |
 |
 |
dlute
|
| Posted: 02/17/2005, 8:28 AM |
|
Thanks Nicole that fixed that problem.
I spent a couple more hours trying to get 4 columns across per row and I can't get it to work at all.
I've made 2 columns across before by using the Alt row and changing some HTML But this just makes one column and the I get a </tr><tr> on every 8th row.
I must be missing something that's obvious again.
Thank You,
Dale
|
|
|
 |
|