rendercell doesnt display as expected in list view

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

rendercell doesnt display as expected in list view

Postby tomhousley » Mon Oct 19, 2009 2:21 pm

Hello,

I have two tables:

tbl_history
tbl_organisation

In list view for tbl_history, the organisation name is shown (which is generated because of the vocabulary in field.ini pulling that from valuelists.ini, and when clicked takes me to the correct record in the tbl_history.

When the organisation name is clicked in list view of tbl_history I want this to load the edit view of the organisation. I have achieved this by rendercell:

Code: Select all
function org_id__renderCell(&$record){
return '<a href="index.php?-action=browse&-table=tbl_organisation&org_id='.$record->strval('org_id').'">'.$record->val('org_id').'</a>';
}


This works, but the problem is the the organisation name is no longer shown, just the org_id.

If I change the code to:

Code: Select all
function org_id__renderCell(&$record){
return '<a href="index.php?-action=browse&-table=tbl_organisation&org_id='.$record->strval('org_id').'">'.$record->val('org_name').'</a>';
}


... then nothing is rendered in the cell.

How to I show the organisation name as defined in valuelists.ini ?

Any help would be gratefully received.

Many thanks, Tom
tomhousley
 
Posts: 52
Joined: Thu Feb 26, 2009 1:02 am
Location: United Kingdom

Postby shannah » Mon Oct 19, 2009 4:14 pm

If you are using a vocabulary on the org_id field then you can just do:
$record->display('org_id') instead of $record->val('org_id').

the display method uses vocabulary values when available. val() and strval() do not.

It is sort of like a food chain:

val() : Returns the raw value (may be int, array, or string, etc..)
strval(): Returns the raw value converted to a string (basically how it is saved in the db).
display() : Returns a display-ready version of the data. This includes converting ids into their corresponding values as specified in a vocabulary.
htmlValue() : Like display but renders for HTML display. e.g. encodes special chars, uses <br> instead of \n etc..


-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Postby tomhousley » Tue Oct 20, 2009 12:43 am

Thank you Steve, works a treat.
tomhousley
 
Posts: 52
Joined: Thu Feb 26, 2009 1:02 am
Location: United Kingdom


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 28 guests

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