Page 1 of 1

Display record owner at table view

Posted: 2018-06-28 10:23
by mysh_eireannach
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 18121 times
Thanks!

Re: Display record owner at table view

Posted: 2018-06-28 15:11
by pbottcher
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.

Re: Display record owner at table view

Posted: 2018-06-28 16:03
by mysh_eireannach
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

Re: Display record owner at table view

Posted: 2018-06-28 16:46
by pbottcher
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`"]);
}

Re: Display record owner at table view

Posted: 2019-10-08 10:57
by mysh_eireannach
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!

Re: Display record owner at table view

Posted: 2025-02-07 10:53
by SkayyHH
Hi, please - how i can do this? I need that code for the "calculated field". Thank you very much!

Re: Display record owner at table view

Posted: 2025-03-07 10:50
by xbox2007
nice Tricks ,
thanks a lot

Re: Display record owner at table view

Posted: 2025-03-09 09:48
by pbottcher
The SQL is already in the code.

Code: Select all

SELECT memberid from membership_userrecords where pkvalue=jobsplanning.id and tablename='jobsplanning'
you would only need to adjust it to the calculated field syntax to make it generic.

Code: Select all

SELECT memberid from membership_userrecords where pkvalue='%ID%' and tablename='%TABLENAME%'