This topic is locked
[SOLVED]

 Adding snippet as custom column in data grid

4/16/2017 9:27:45 AM
PHPRunner General questions
Z
Zerobaka author

Hello people.

Nice to meet you, and i humbly request of an assistance for my problem here.
I try to add few custom columns inside my list/data grid, it basically retrieve data from current record, and

alter it, and lastly, present it.
I try looking the manual, and end up with these lines:
1)

// Put your code here.

global $pageObject;
$data = $pageObject->getCurrentRecord();

$remains = $data["total"] - $data["downpay"];

echo "$ ".$remains;
2)

// Put your code here.

global $pageObject;
$data = $pageObject->getCurrentRecord();

if ($data["status"]==0)

echo "Not yet";

else

echo "Complete";
3)

// Put your code here.

global $pageObject;
$data = $pageObject->getCurrentRecord();

$date1 = $data["date_making"];

$date2 = now();
$interval = $date2 - $date1;

$days = floor($interval / (60 60 24));

echo $days." days";
And guess what? None of them works.

Any hits, or advice, or comments, o good people? Thanks before.
Best regards, Abe

Z
Zerobaka author 4/16/2017

Hey people,
I kind a realize that the lines i shows you guys before is working IF... it placed inside snippets that placed

inside add/edit/view pages.
So, can anyone help me and show me how its done inside data grid/list pages?

Thanks before then.
Best regards, Abe

Admin 4/17/2017

Code snippets executed once on the page, won't work for your purposes. What you need to do is to set 'View as' type of one of fields to Custom and place your code there:

https://xlinesoft.com/phprunner/docs/_view_as__settings_custom.htm

Z
Zerobaka author 4/17/2017



Code snippets executed once on the page, won't work for your purposes. What you need to do is to set 'View as' type of one of fields to Custom and place your code there:

https://xlinesoft.com/phprunner/docs/_view_as__settings_custom.htm


Thanks for answering, Admin, but i was hoping there is a way to retrieve the content of other field without actually using any field at all.

So content of the column only represents the result of alteration/calculation from the actual field(s).

Other ways, i had to alter the table structure, and i think its not very good idea, right now.
Is there really no such method prepared within PHPRunner?

Thanks anyway, Mr. Admin.
Best regards, Abe.

Admin 4/19/2017

You do not need to modify table structure. Add a new calculated field to your SQL Query, make it appear on List page only and use 'View as' Custom on this field.

Z
Zerobaka author 4/20/2017



You do not need to modify table structure. Add a new calculated field to your SQL Query, make it appear on List page only and use 'View as' Custom on this field.


I see... that makes sense. Thanks Admin.

And, do you mind to give an example of this calculated field, since I kind of lost of how...

Sorry, and
Best regards, Abe

Z
Zerobaka author 4/20/2017

Actually, i kind of figure it out myself, so thankyou mr Admin.

Here is the code i need::



DATEDIFF(CURDATE(), tgl_buat) AS umur,


Thanks again, i am really thankfull.
Best regards, Abe.