Adjust column value before export

QuestionsAdjust column value before export
Michael Murphy asked 4 years ago

One of my columns uses an on_data_display function so that cells in that column are conditionally shown as links (based on contents of other columns). For example, some cells in that column might have the following content:

<a target='_blank' style='cursor:pointer; color:darkblue; text-decoration:underline; font-weight:bold;' href='/ran/plan/frontSheetENew1.php?id4G={$data["id4G"]}'>{$data["nominal"]}</a>

While others might simply have:

$data["nominal"]

However, when I export rows in csv format, I’d like for all cells in this column to have the simple $data["nominal"] format, rather than showing as the full <a> tag like the above.

I played around with an on_export function, but couldn’t find any way of adjusting the values in the cell as they were exported.

Is this possible?

3 Answers
Abu Ghufran Staff answered 4 years ago

Easy way to achieve results is to have 2 columns with same field source, #1 with link and #2 plain value.

For #1 with link, set no to show in export
$col[“export”] = false;

For #2, set to show in export and hidden rest
$col[“export”] = true;
$col[“hidden”] = false;

Hope it helps.

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Michael Murphy answered 4 years ago

Thanks for the suggestion Abu.

Is it necessary to SELECT the column twice in the select_command query? Or can I have two different grid columns both reference the same field from the query? I couldn’t figure out how to make that work, and had to go with separate fields in the query, but would prefer the second way for cleanliness.

Abu answered 4 years ago

Hi,

I review your query but currently it’s not doable with single field.

Your Answer

15 + 13 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?