Select and order fields for a subform by the user and output

Questions related to customising nuBuilder Forte with Javascript or PHP.

Select and order fields for a subform by the user and output

Postby ernesttan1976 » Sat Aug 01, 2020 4:09 pm

Hi to all, I really appreciate the developers of this software.

I created a subform called employees.
In this subform I am able to edit the fields which is really cool.

For browse forms, there is a print and download to csv feature which I very much appreciate. I want to be able to select and order the fields shown in the subform so that it is user customizable, and then the user can output it as a csv.

May I know how to go about this?
Attachments
Columns Selector.jpg
Columns Selector.jpg (61.02 KiB) Viewed 414 times
Subform.jpg
Subform.jpg (332.03 KiB) Viewed 414 times
ernesttan1976
 
Posts: 18
Joined: Sat May 16, 2020 5:38 pm

Re: Select and order fields for a subform by the user and ou

Postby kev1n » Sat Aug 01, 2020 7:16 pm

I'm afraid it'is not so easy to change the order of the columns/fields.
To output just certain fields in the CSV, you would have to write your own custom JS or PHP function. Maybe someone else will come up with other ideas.
kev1n
 
Posts: 969
Joined: Mon Oct 15, 2018 2:13 am

Re: Select and order fields for a subform by the user and ou

Postby gerese » Sun Aug 02, 2020 2:32 am

For example, you can create 4 different forms using the same table, in which the order or number of columns is closest to the user's needs.
nuBuilderForte .... BIG Like !!!
gerese
 
Posts: 41
Joined: Mon Dec 17, 2018 2:43 am

Re: Select and order fields for a subform by the user and ou

Postby Janusz » Sun Aug 02, 2020 4:25 am

Maybe you can try to generate CSV from the MariaDB using PHP procedure and store it on the server.
Next open saved file from nuBuilder.
Something like that (PHP procedure):

Code: Select all
unlink('/var/www/html/TestDB/temp/customers.csv');

$q ="
SELECT kon_nazwisko, kon_email, kon_tel INTO OUTFILE '/var/www/html/TestDB/temp/customers.csv'
  FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"'
  LINES TERMINATED BY '\n'
  FROM Kontakty;
";

nuRunQuery($q);

$x="window.open ('temp/customers.csv',\"myWindow\");";

nuJavascriptCallback($x);

You can create $q variable with JS and send it to the PHP (or better just a part of it).
Procedure you can run with:
nuRunPHPHidden('CSV_test', '1');

it's just an idea not well tested - but the attached code was working with quick test with my data.
Janusz
 
Posts: 333
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Select and order fields for a subform by the user and ou

Postby ernesttan1976 » Mon Aug 03, 2020 12:48 pm

Thanks Kevin cheers!

Janusz, thank you very much for your help! :D :) I will try it out and post my result. :D :)
ernesttan1976
 
Posts: 18
Joined: Sat May 16, 2020 5:38 pm

Re: Select and order fields for a subform by the user and ou

Postby Janusz » Tue Aug 04, 2020 4:30 am

If you want to "separate" the file user by user and add column names you can run following procedure:
Code: Select all
$file="#user_id#customers.csv";
$list= " kon_nazwisko, kon_email , kon_tel ";
$table= " Kontakty ";
$column_names=" 'Col_1', 'Col_2', 'Col_3' ";

unlink("/var/www/html/TestDB/temp/$file");

$q ="
SELECT *
INTO OUTFILE '/var/www/html/TestDB/temp/$file'
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\"'
LINES TERMINATED BY '\n'
FROM
(SELECT $column_names
UNION
SELECT $list FROM $table) AS temp
";

nuRunQuery($q);
$x="window.open ('temp/$file',\"myWindow\");";

nuJavascriptCallback($x);
Janusz
 
Posts: 333
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: Select and order fields for a subform by the user and ou

Postby kev1n » Tue Aug 04, 2020 5:15 pm

I'm developing a script that will allow you to hide and rearrange columns of a subform. I'll need some more time to finalize it but here's a sneak peek:
Attachments
subform_hide_rearrange_columns.gif
subform_hide_rearrange_columns.gif (158.24 KiB) Viewed 345 times
kev1n
 
Posts: 969
Joined: Mon Oct 15, 2018 2:13 am

Re: Select and order fields for a subform by the user and ou

Postby kev1n » Tue Aug 04, 2020 6:00 pm

PS: Kindly refrain from asking multiple questions in the same thread. If people start answering multiple questions in the one thread, it becomes very confusing very quickly and it makes it harder for everyone.
kev1n
 
Posts: 969
Joined: Mon Oct 15, 2018 2:13 am


Return to Custom Code



cron