How to save selected column to export CSV

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
soewandi
Veteran Member
Posts: 34
Joined: 2019-11-20 14:00

How to save selected column to export CSV

Post by soewandi » 2024-08-10 02:09

I want to save selected column (e.g. column 1, 3, 5) when export to CSV File. AG default always save all fields. Please help me, and many thanks for your help.

My regards,
Soewandi

User avatar
zibrahim
Veteran Member
Posts: 160
Joined: 2020-01-28 18:30
Location: Malaysia

Re: How to save selected column to export CSV

Post by zibrahim » 2024-08-11 00:40

Hi there,
You can customise the columns etc by specifying the query in the hooks/TABLENAME.php file.
Scroll down to the bottom, you should see the line like this...

Code: Select all

function TABLENAME_csv($query, $memberInfo, &$args) {
Then, put your query inside the curly bracket above the return $query; statement
Example:

Code: Select all

function booking_csv($query, $memberInfo, &$args) {
	$query = "SELECT `booking`.`id` AS booking_id, `customer`.`name` AS customer FROM `booking` LEFT JOIN `customer` ON `booking`.`customer_id` = `customer`.`id` WHERE 1 = 1 ORDER BY `booking`.`id`";

	return $query;
}
If nothing happen after you click the Save CSV button, you might want to check if there is any error in your query under Admin Area -> Utilities -> Query logs

Have a nice day.
Zala.
Appgini 24.17, MacOS 14.6 Windows 11 on Parallels.

soewandi
Veteran Member
Posts: 34
Joined: 2019-11-20 14:00

Re: How to save selected column to export CSV

Post by soewandi » 2024-08-11 11:10

Yes, you exactly helped me. :D Many thanks Mr. Zibrahim

My warm regards
soewandi

Post Reply