Customise returned data format on view tab

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

Customise returned data format on view tab

Postby m23k » Mon Oct 29, 2012 4:13 am

Hi

With the fieldname__renderCell() function I have been able to add for example "GB" to the output for HDD size storage on the list page. Ie. I have 250 stored in the database but it outputs it as "250 GB" in the list table.

How can I do this on the view page specific to the record though?

Thanks!
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am

Re: Customise returned data format on view tab

Postby shannah » Mon Oct 29, 2012 8:08 am

You could actually hit two birds with one stone by just implementing the fieldname__display() method.
--
Steve Hannah
@shannah78 (on twitter)
sjhannah.com blog
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Customise returned data format on view tab

Postby m23k » Tue Oct 30, 2012 5:08 am

Thanks, it even mentions that in the wiki I've just realised!

A heads up to others finding this thread:

Before I was using $record->display('field_name') in my fieldname__renderCell() function to display the value. This obviously went loopy (out of memory errors) when switching to using fieldname__display() function as it was doing its self in its self ;)

I changed to using $record->strval('fieldname') instead. Brill. Working.

Except.. I still need to want to add div's to my cells so I can not wrap them. So you use renderCell() as well still like this.

Ie:
Code: Select all
function ram__renderCell(&$record){
    return '<div style="white-space: nowrap;">'.$record->display('ram').'</div>';
}

function screen_size__display(&$record){
    return $record->strval('ram').' GB';
}
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am

Re: Customise returned data format on view tab

Postby auphi » Tue Oct 30, 2012 12:29 pm

Good call on using $record->strval() in the fieldname__display(). I wish you'd posted this 2 weeks ago; it would have saved me a lot of frustration. =P

I don't know what your intentions are with wraping, but just to throw this out there, if you wanted to go ahead and make all of your cells nowrap, you can create your own custom style sheet (if you haven't already) and toss in

Code: Select all
.listing { white-space:nowrap; }

so that you don't have to manually do it for every cell.
auphi
 
Posts: 20
Joined: Sun Oct 21, 2012 7:39 pm

Re: Customise returned data format on view tab

Postby m23k » Wed Oct 31, 2012 2:50 am

Thank you auphi!!

Yes, that indeed knocked that one on the head, and it applies it to the table headers aswell meaning I know longer have to use a div with min-width on certain fields too as that wasn't applying the no wrap to table headers just cells!

:D
m23k
 
Posts: 19
Joined: Sun Oct 28, 2012 10:53 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 25 guests

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