Formatting in _cm_listView_header() method [message #2415] |
Thu, 21 January 2010 15:25 |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
Tony,
Further to all the recent discussion and changes around formatting when producing PDF output I have a question about formatting when using the _cm_listView_header() method. I've recently moved some code that sets substitution tokens into this method (it's where it should have been anyway) but the standard date formatting does not seem to be applied.
Is there something about the order of events for printing the header that I need to take into account?
Thanks.
|
|
|
|
|
|
|
|
|
|
|
|
Re: Formatting in _cm_listView_header() method [message #2425 is a reply to message #2424] |
Fri, 22 January 2010 08:42 |
AJM
Messages: 2363 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I had not realised that you expected the data to be formatted BEFORE the call to _cm_listView_header(). Is this what you want?
Which is more logical to you? Perform the formatting on the row data BEFORE or AFTER the call to _cm_listView_header()? This would mean that if you want any changes made in _cm_listView_header() to be formatted then you will have to do it yourself.
It would be a simple cange to make - just move line 22 to below line 25.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Formatting in _cm_listView_header() method [message #2427 is a reply to message #2426] |
Fri, 22 January 2010 09:16 |
AJM
Messages: 2363 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
Upon reflection it would be more logical to format the data BEFORE the call to _cm_listView_header() as you can only modify the contents of the current row.
With the _cm_ListView_print_before() and _cm_ListView_print_after() methods you are not amending the current row but optionally adding new rows, so it is correct that any formatting is done afterwards.
Modified file is attached.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|
Re: Formatting in _cm_listView_header() method [message #2429 is a reply to message #2428] |
Fri, 22 January 2010 11:38 |
AJM
Messages: 2363 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You are confusing me now because your earlier problem was with the formatting of dates.
If you want to stop a ValRep field from being automatically changed into its representation then you need to amend the contents of the $fieldspec entry so that the formatData() method does not overwrite the field value with the external representation.
If you need to work with both the value and the representation you should put two separate fields into the row data before any formatting or custom processing is performed.
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
Re: Formatting in _cm_listView_header() method [message #2430 is a reply to message #2415] |
Fri, 22 January 2010 11:42 |
gpatti
Messages: 283 Registered: August 2008
|
Senior Member |
|
|
Tony,
The formatted data now contains data that has been converted by _cm_getValRep(). So $rowdata contains representation data rather than the value.
Prior to te latest change $rowdata contained values rather than representations.
What is the correct/easiest way to obtain the original value for these items?
Sorry - just spotted your previous post so you can ignore this.
[Updated on: Fri, 22 January 2010 11:44] Report message to a moderator
|
|
|
Re: Formatting in _cm_listView_header() method [message #2431 is a reply to message #2430] |
Fri, 22 January 2010 11:50 |
AJM
Messages: 2363 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I identified two possibilities in my previous post:
(1) Amend the $fieldspec entry so that the formatData() method will not swap the value with the representation.
(2) After reading the record but before the call to _cm_listView_header() or formatData() put a copy of the original value into the row data with another name. As this will not have an entry in the $fieldspec array it will not be reformatted.
If you need to work with the unformatted value but display the formatted value then I would go for option (2).
Tony Marston
http://www.tonymarston.net
http://www.radicore.org
|
|
|
|