Display record owner at table view

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
mysh_eireannach
Veteran Member
Posts: 35
Joined: 2016-02-16 22:31

Display record owner at table view

Post by mysh_eireannach » 2018-06-28 10:23

Hi All!

Could anyone share tips please, how to display at table view one extra column with record owner.

Like on the picture below:
Untitled-1345.png
Untitled-1345.png (29 KiB) Viewed 3604 times
Thanks!

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Display record owner at table view

Post by pböttcher » 2018-06-28 15:11

Hi,

one possibilty is that you create an additional field (lets call it "owner") to your table (I use "jobsplanning" as the table and id as the pk) in this post.
Make this field read-only in AppGini.

Next you generate your project and after that you edit the jobsplanning_view.php file.

Search for the part
// Fields that can be displayed in the table view
$x->QueryFieldsTV = array(

should be around line 23.

You will see the at the end of the array your new field owner.
Replace the code with the following:

Code: Select all

"IF( CHAR_LENGTH((SELECT memberid from membership_userrecords where pkvalue=jobsplanning.id and tablename='jobsplanning')), CONCAT_WS('', (SELECT memberid from membership_userrecords where pkvalue=jobsplanning.id and tablename='jobsplanning')), '')  /* owner */" => "owner"

You can also replace the code in the other arrays:
$x->QueryFieldsCSV = array(
$x->QueryFieldsFilters = array(
$x->QueryFieldsQS = array(

This should to the trick.

Please note that you will no see the information in the detail view of the record.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

mysh_eireannach
Veteran Member
Posts: 35
Joined: 2016-02-16 22:31

Re: Display record owner at table view

Post by mysh_eireannach » 2018-06-28 16:03

Hi Pböttcher

Thank you so much!!!

Yes, that work perfect! And do the trick.

One more question:

Would be possible some how convert this trick as hook, to save manually change every single time after generate project at AppGini?

Thnaks

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Display record owner at table view

Post by pböttcher » 2018-06-28 16:46

Yes, this should work as well:

via the hooks/jobsplanning.php.

Code: Select all

function jobsplanning_init(&$options, $memberInfo, &$args){

	$mystr="IF( CHAR_LENGTH((SELECT memberid from membership_userrecords where pkvalue=jobsplanning.id and tablename='jobsplanning')), CONCAT_WS('', (SELECT memberid from membership_userrecords where pkvalue=jobsplanning.id and tablename='jobsplanning')), '')  /* owner */" => "owner";
	$options->{"QueryFieldsTV"}[$mystr]=$options->{"QueryFieldsTV"}["`jobsplanning`.`owner`"];
	$options->{"QueryFieldsCSV"}[$mystr]=$options->{"QueryFieldsTV"}["`jobsplanning`.`owner`"];
	$options->{"QueryFieldsFilters"}[$mystr]=$options->{"QueryFieldsTV"}["`jobsplanning`.`owner`"];
	$options->{"QueryFieldsQS"}[$mystr]=$options->{"QueryFieldsTV"}["`jobsplanning`.`owner`"];
	unset($options->{"QueryFieldsTV"}["`jobsplanning`.`owner`"]);
	unset($options->{"QueryFieldsCSV"}["`jobsplanning`.`owner`"]);
	unset($options->{"QueryFieldsFilters"}["`jobsplanning`.`owner`"]);
	unset($options->{"QueryFieldsQS"}["`jobsplanning`.`owner`"]);
}
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

mysh_eireannach
Veteran Member
Posts: 35
Joined: 2016-02-16 22:31

Re: Display record owner at table view

Post by mysh_eireannach » 2019-10-08 10:57

Hi Pböttcher

Thank you so much for your help last time!!!

Now using the new version AppGini 5.80 we can add same information into app using "Calculated fields" MySQL query, I'm right?

Could I ask please for sample of SQL query using same Idea as in original post.

Many thanks!

Post Reply