A question on the %fieldname%__renderCell( &$record ) method

A place for users and developers of the Xataface to discuss and receive support.

Postby Markus » Fri Jul 20, 2007 6:38 am

Hi Steve,

I tested the %fieldname%__renderCell( &$record ) method in the DelegateClass of my table umruest and had a problem.

When I have

function L_SID__renderCell( &$record ){
if ($record->strval('L_SID')){
return $record->getValue('L_SID').' (strval('L_SID').'">zeigen)';
}
else return " ";
}

I will have the $record->getValue('L_SID') shown with the correct link e.g. works fine.

Now I want to have not the id (L_SID) of the record in list_system table but the name which is sys_name.

I tried to catch the value of this with $sys_name=$record->getValue('sys_name'); in the following but it did not occur.
Instead I will get the link without the id and without sys_name values.


function L_SID__renderCell( &$record ){
if ($record->strval('L_SID')){
$sys_name=$record->getValue('sys_name');
return $sys_name.' (strval('L_SID').'">zeigen)';
}
else return " ";
}

My valuelist in valuelists.ini is as follows:

[system]
__sql__ = "SELECT list_system.l_sid, list_system.sys_name FROM umruest LEFT JOIN list_system ON umruest.L_SID=list_system.l_sid ORDER BY list_system.sys_name"


Where did I go wrong here?

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm

Postby shannah » Fri Jul 20, 2007 8:37 am

Ways to retrieve values from a dataface record:

1. getValue() : gets the raw value as stored in the db. (aka val())
2. getValueAsString() : gets raw value - but guaranteed to be type string. (aka strval())
3. display() : Gets the value as it should be displayed. This will substitute the value from the valuelist if it uses a valuelist.
4. htmlValue() : Gets the value formated for HTML. In non-htmlarea fields this will clean up special characters so they can be displayed on an html page.

I believe you probably want to use the display() method on the L_SID column to obtain the sys_name.

e.g.
$record->display('L_SID'); // this will return the sys_name value, because it is substituted by the valuelist
vs
$record->strval('L_SID'); // this will return the actual ID.

-Steve
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby Markus » Fri Jul 20, 2007 9:59 am

Hi Steve,

that works DFantastic ;)

Thank you for explaining the different ways too. Think I will use this in the future.

Markus
Markus
 
Posts: 94
Joined: Wed Dec 31, 1969 5:00 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 23 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved