beshoo
Posts: 68
|
| Posted: 11/03/2009, 7:35 AM |
|
Dear all
i have a Grad , i want to insert a new rows after the normal row that i get form SQL select .
i believe i have to set an attribute
<!-- BEGIN Row -->
<tr {cash_account:rowStyle}>
<td>{description}</td>
</tr>
{cash_account:tr_td}
<!-- END Row -->
and in before show i have to cal TPL function or some thing please may you advice !
the target of this : i want to list tree menu in a grad and the Main row is the parent , befor show i will get the children of the parent and set an indent
Main Row
|_ New Row1
|_ New Row 1 1
|_ New Row 1 1 1
|_ New Row 2
Main Row 2
if there is a solution other tan this please advice
_________________
beshoo Love PHP and CC 4.2 |
idh63
Posts: 76
|
| Posted: 11/06/2009, 7:22 AM |
|
Hi,
I think that I am following what you want to do here.
You could write some custom code in BeforeShowRow.
Create some script to retrieve your related data with the formatting you want
Then you could choose to show {cash_account:tr_td} only if there is related data.
I don't see that you need to go anywhere near Global $tpl and in fact CCS discourages this practice in V4.x
Just use something like:
$db = new clsDBConnection1(); //or whatever you connection name is.
$primary_key = $Container->ds->Record['primary_key_column_name'];
$sql = "Select statement that retrieves related records WHERE primary_key_column_name = " . $primary_key;
$pad_amt = 10;
$pad = 10;
$formatted = '';
while( $db->next_record() ) {
$formatted[] = '<tr><td style="padding-left:' . $pad . 'px;">' . $db->f(0) . '</td></tr>';
$pad+$pad_amt;
}
if (is_array($formatted)) {
$formatted = implode('', $formatted);
$Container->cash_account->Attributes->SetValue('tr_td', $formatted);
}
Hope this helps.
|